feat: dump players.json without userId

This commit is contained in:
mokurin000
2025-08-02 22:31:04 +08:00
parent 0d9c8c79b4
commit 03dc2eea94
2 changed files with 22 additions and 2 deletions

4
.gitignore vendored
View File

@@ -3,6 +3,6 @@
/*.txt
/players.redb
/players.json*
/test.json
/players*.json*
/b50*.json*

20
utils/export_players.py Normal file
View File

@@ -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)