diff --git a/minimal_auth.py b/minimal_auth.py index 5c317a6..04b11ce 100644 --- a/minimal_auth.py +++ b/minimal_auth.py @@ -2,6 +2,9 @@ import getpass # hides types characters, very useful import json import sys import hashlib +import random +import string + def get_credentials(): username = input('Enter your username: ') @@ -28,6 +31,19 @@ def write_pwdb(pwdb, pwdb_path): pwdb_file = open(pwdb_path, 'wt') json.dump(pwdb, pwdb_file) +def get_salt(char_num=10): + """Create random string of characters + + Parameters + ---------- + char_num: int. + Number of random characters to be created. + """ + + salt = ''.join(random.choices(string.ascii_uppercase + string.digits, k=char_num)) + + return salt + pwdb_path = 'pwdb.json' pwdb = read_pwdb(pwdb_path)