summaryrefslogtreecommitdiff
path: root/createDB.py
diff options
context:
space:
mode:
Diffstat (limited to 'createDB.py')
-rw-r--r--createDB.py35
1 files changed, 35 insertions, 0 deletions
diff --git a/createDB.py b/createDB.py
new file mode 100644
index 0000000..6ff7f76
--- /dev/null
+++ b/createDB.py
@@ -0,0 +1,35 @@
+import sqlite3
+from blake3 import blake3
+from random import randrange
+
+con = sqlite3.connect("likes.db")
+cur = con.cursor()
+cur.execute("""CREATE TABLE IF NOT EXISTS likes(
+ ip_hash TEXT NOT NULL,
+ path TEXT NOT NULL,
+ lastMod INT NOT NULL,
+ number UNSIGNED INT NOT NULL,
+ PRIMARY KEY (ip_hash, path)
+)""")
+con.commit()
+con.close()
+
+con = sqlite3.connect("likes.db")
+cur = con.cursor()
+
+path = "bizarreries-du-langage-c"
+
+for _ in range(1000):
+ hashIP = blake3(f'127.0.0.{randrange(2, 256)}'.encode()).hexdigest()
+ cur.execute("INSERT OR IGNORE INTO likes VALUES (?, ?, unixepoch(), 0)", [hashIP, path])
+ cur.execute("UPDATE likes SET number = number + 1, lastMod = unixepoch() WHERE ip_hash = ? and path = ?", [hashIP, path])
+
+con.commit()
+
+
+for i in range(2, 256):
+ if blake3(f'127.0.0.{i}'.encode()).hexdigest() == "d329429a1928ac4f31fe07b0c87bcbd129d70e191c85516a180fa4101f5eaae8":
+ print(f"i == {i} => {blake3(('127.0.0.' + str(i)).encode()).hexdigest()}")
+
+
+con.close()