Skip to content

Commit

Permalink
Update encrypt_password.py
Browse files Browse the repository at this point in the history
  • Loading branch information
zywkloo authored Jan 18, 2024
1 parent 276110f commit dfc3f29
Showing 1 changed file with 0 additions and 34 deletions.
34 changes: 0 additions & 34 deletions src/passwordler/encrypt_password.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,37 +49,3 @@ def encrypt_password(message, random_seed=123):
encrypted_msg = ''.join(encrypted_msg)

return encrypted_msg


def decrypt_password(encrypted_message, random_seed=123):
"""
Decrypt a message encrypted with the simple substitution cipher.
This function decrypts a given message by mapping each character back to its original character
using the same shuffled character set used for encryption. The function requires the same random
seed that was used for encryption to ensure consistent shuffling.
Parameters:
encrypted_message (str): The message to be decrypted.
random_seed (int): The seed used for random shuffling (should be the same as used in encryption).
Returns:
str: The decrypted message.
"""
random.seed(random_seed)

decryption = original.copy()
random.shuffle(decryption)

keyMap = getKeyMap(decryption, isDecryption=True)
decrypted_msg = []

for character in encrypted_message:
if character in keyMap:
decrypted_msg.append(keyMap[character])
else:
decrypted_msg.append(character)

decrypted_msg = ''.join(decrypted_msg)

return decrypted_msg

0 comments on commit dfc3f29

Please sign in to comment.