salting_fix #16

Open
julioro wants to merge 3 commits from julioro/2025-plovdiv-git:salting_fix into live_coding
Showing only changes of commit 9581753e99 - Show all commits

View file

@ -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)