24 lines
443 B
Python
Executable File
24 lines
443 B
Python
Executable File
#!/usr/bin/env python3
|
|
|
|
import sys, json, hashlib, base64
|
|
|
|
field = sys.argv[1]
|
|
if len(sys.argv) > 2:
|
|
fieldout = sys.argv[2]
|
|
else:
|
|
fieldout = field
|
|
|
|
out = json.load(sys.stdin)
|
|
|
|
for item in range(len(out)):
|
|
out[item][fieldout] = (
|
|
base64.b64encode(
|
|
hashlib.sha1(bytes(out[item][field], "utf-8")).digest(), altchars=b"-_"
|
|
)
|
|
.decode("utf-8")
|
|
.replace("=", "")
|
|
)
|
|
|
|
print(json.dumps(out))
|
|
|