saltpass.py: Implement simple salted hash script

This commit is contained in:
theoreticalbts 2015-07-07 15:57:29 -04:00
parent d31e0108b4
commit ad7d0841c2
2 changed files with 26 additions and 0 deletions

3
.gitignore vendored
View file

@ -33,3 +33,6 @@ witness_node_data_dir
programs/witness_node/object_database/* programs/witness_node/object_database/*
object_database/* object_database/*
*.pyc
*.pyo

View file

@ -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=(',', ' : ')
))