salting_fix #16
1 changed files with 16 additions and 0 deletions
|
@ -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)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue