summaryrefslogtreecommitdiff
path: root/createDB.py
blob: c72620f3b7512985b23bb268817c2ca5e4a2a8f4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
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()