-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathset_access_code.py
More file actions
40 lines (29 loc) · 887 Bytes
/
set_access_code.py
File metadata and controls
40 lines (29 loc) · 887 Bytes
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
38
39
40
"""Set the 6-character access code for the bracket entry page.
Usage:
uv run set_access_code.py MYCODE
"""
import hashlib
import sys
def main():
if len(sys.argv) != 2 or len(sys.argv[1]) != 6:
print("Usage: uv run set_access_code.py <6-char-code>")
sys.exit(1)
code = sys.argv[1]
hash_hex = hashlib.sha256(code.encode()).hexdigest()
entry_path = "docs/entry.html"
with open(entry_path) as f:
content = f.read()
# Replace the placeholder or existing hash
import re
content = re.sub(
r"const ACCESS_HASH = '[^']*';",
f"const ACCESS_HASH = '{hash_hex}';",
content,
)
with open(entry_path, "w") as f:
f.write(content)
print(f"Access code set: {code}")
print(f"SHA-256 hash: {hash_hex}")
print(f"Updated: {entry_path}")
if __name__ == "__main__":
main()