implemented working fingerprinting prototype
This commit is contained in:
33
common/src/main/resources/deviceFingerprinting/gen_packs.py
Normal file
33
common/src/main/resources/deviceFingerprinting/gen_packs.py
Normal file
@@ -0,0 +1,33 @@
|
||||
import zipfile
|
||||
import hashlib
|
||||
import uuid
|
||||
import json
|
||||
|
||||
SERVER_URL = "http://localhost:8080/api/devicefingerprinting"
|
||||
packs = []
|
||||
|
||||
def file_sha1(path):
|
||||
h = hashlib.sha1()
|
||||
with open(path, "rb") as f:
|
||||
for chunk in iter(lambda: f.read(8192), b""):
|
||||
h.update(chunk)
|
||||
return h.hexdigest()
|
||||
|
||||
for i in range(0, 24):
|
||||
path = f"packs/{i}"
|
||||
|
||||
with zipfile.ZipFile(path, mode="w") as zf:
|
||||
zf.writestr(
|
||||
"pack.mcmeta",
|
||||
'{"pack":{"pack_format":22,"supported_formats":[22,1000],"description":"pack ' + str(i) + '"}}',
|
||||
)
|
||||
|
||||
hash = file_sha1(path)
|
||||
packs.append({
|
||||
"url": f"{SERVER_URL}/packs/{i}",
|
||||
"uuid": str(uuid.uuid4()),
|
||||
"hash": hash
|
||||
})
|
||||
|
||||
with open("packs.json", "w") as f:
|
||||
json.dump(packs, f, indent=4)
|
||||
Reference in New Issue
Block a user