diff --git a/.gitignore b/.gitignore index a6c3b4e..0e38b55 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,6 @@ /*.txt /players.redb -/players.json* -/test.json \ No newline at end of file +/players*.json* +/b50*.json* \ No newline at end of file diff --git a/utils/export_players.py b/utils/export_players.py new file mode 100644 index 0000000..88f1891 --- /dev/null +++ b/utils/export_players.py @@ -0,0 +1,20 @@ +import json +import hashlib + +SALT = b"Lt2N5xgjJOqRsT5qVt7wWYw6SqOPZDI7" + + +def salted_hash_userid(player: dict): + uid = player["userId"] + hash_uid = hashlib.sha256(f"{uid}".encode("utf-8") + SALT) + player["userId"] = hash_uid.hexdigest() + + +def main(): + with open("players.json", "r", encoding="utf-8") as f: + data = json.load(f) + for entry in data: + salted_hash_userid(entry) + + with open("players_pub.json", "w", encoding="utf-8") as f: + json.dump(data, f, ensure_ascii=False)