Skip to content

Commit

Permalink
Merge pull request #95 from UBC-MDS/add_in_code_comments
Browse files Browse the repository at this point in the history
fix: added in code comments
  • Loading branch information
zywkloo authored Feb 3, 2024
2 parents b3addc0 + 26fb9dd commit dfbf55e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/passwordler/decrypt_password.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,11 @@ def decrypt_password(encrypted_password, random_seed = 123):
decryption = original.copy()
random.shuffle(decryption)

# generate a key map for decryption
keyMap = getKeyMap(decryption, isDecryption=True)
decrypted_pass = []

# decrypt password with key map
for character in encrypted_password:
if character in keyMap:
decrypted_pass.append(keyMap[character])
Expand Down
2 changes: 2 additions & 0 deletions src/passwordler/encrypt_password.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,11 @@ def encrypt_password(password, random_seed=123):
encryption = original.copy()
random.shuffle(encryption)

# generate a key map for encryption
keyMap = getKeyMap(encryption)
encrypted_pass = []

# encrypt password with key map
for character in password:
if character in original:
encrypted_pass.append(keyMap[character])
Expand Down
7 changes: 6 additions & 1 deletion src/passwordler/password_strength.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ def password_strength(password):
elif password == '':
raise ValueError("'password' cannot be an empty string")

# collect information on the password
count_uppercase = len(re.findall("[A-Z]", password))
count_numbers = len(re.findall('[0-9]', password))
count_special_chars = len(re.findall('[!-/:-@\\[-`{-~]', password))
Expand All @@ -34,10 +35,14 @@ def password_strength(password):
'baseball', 'dragon', 'football', '1234567', 'monkey', 'letmein', 'abc123',
'111111', 'mustang', 'access', 'shadow', 'master', 'michael', 'superman',
'696969', '123123', 'batman', 'trustno1']


# conditions for strong password
if length >= 12 and count_uppercase >= 1 and count_numbers >= 1 and count_special_chars >= 1 and password not in common_passwords:
return 'Your password is: Strong'

# conditions for good password
elif length >= 8 and (count_uppercase + count_numbers + count_special_chars) >= 2 and password not in common_passwords:
return 'Your password is: Good'

else:
return 'Your password is: Weak'

0 comments on commit dfbf55e

Please sign in to comment.