diff --git a/.gitignore b/.gitignore index 5cdb0935..c4d159d2 100644 --- a/.gitignore +++ b/.gitignore @@ -33,3 +33,6 @@ witness_node_data_dir programs/witness_node/object_database/* object_database/* + +*.pyc +*.pyo diff --git a/programs/witness_node/saltpass.py b/programs/witness_node/saltpass.py new file mode 100755 index 00000000..6562fc23 --- /dev/null +++ b/programs/witness_node/saltpass.py @@ -0,0 +1,23 @@ +#!/usr/bin/env python3 + +import base64 +import getpass +import hashlib +import json +import os + +pw = getpass.getpass("enter your password: ") +pw_bytes = pw.encode("utf-8") +salt_bytes = os.urandom(8) +salt_b64 = base64.b64encode( salt_bytes ) +pw_hash = hashlib.sha256( pw_bytes + salt_bytes ).digest() +pw_hash_b64 = base64.b64encode( pw_hash ) + +print(json.dumps( +{ + "password_hash_b64" : pw_hash_b64.decode("ascii"), + "password_salt_b64" : salt_b64.decode("ascii"), +}, +sort_keys=True, +indent=3, separators=(',', ' : ') +))