adds function to create salt for passwords. Salting process not yet implemented

This commit is contained in:
ASPP Student 2025-09-22 16:23:21 +03:00
parent e149ba7724
commit 9581753e99

View file

@ -2,6 +2,9 @@ import getpass # hides types characters, very useful
import json import json
import sys import sys
import hashlib import hashlib
import random
import string
def get_credentials(): def get_credentials():
username = input('Enter your username: ') username = input('Enter your username: ')
@ -28,6 +31,19 @@ def write_pwdb(pwdb, pwdb_path):
pwdb_file = open(pwdb_path, 'wt') pwdb_file = open(pwdb_path, 'wt')
json.dump(pwdb, pwdb_file) 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_path = 'pwdb.json'
pwdb = read_pwdb(pwdb_path) pwdb = read_pwdb(pwdb_path)