Skip to content

Commit

Permalink
remove code
Browse files Browse the repository at this point in the history
  • Loading branch information
zywkloo committed Jan 12, 2024
1 parent 270d08d commit e88482b
Showing 1 changed file with 1 addition and 22 deletions.
23 changes: 1 addition & 22 deletions src/passwordler/password_encryption.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
from Crypto.Cipher import AES
import os

def password_encryption(raw_password: str, encrypt_algo: list = ['AES']) -> str:
"""
Encrypt a given password.
Expand All @@ -14,22 +11,4 @@ def password_encryption(raw_password: str, encrypt_algo: list = ['AES']) -> str:
Returns:
str: The encrypted password.
"""

# Define block size and padding function for AES
BS = AES.block_size
pad = lambda s: s + (BS - len(s) % BS) * chr(BS - len(s) % BS)

# Only AES is implemented, for now, raise error for other algorithms
if 'AES' not in encrypt_algo or len(encrypt_algo) > 1:
raise NotImplementedError("Currently, only AES encryption is implemented.")

# Generate a random key for AES encryption
key = os.urandom(32) # AES requires a key of 16, 24, or 32 bytes

# Encrypt the password
cipher = AES.new(key, AES.MODE_ECB)
encrypted_password = cipher.encrypt(pad(raw_password))

# Returning the encrypted password as a hexadecimal string for readability
return encrypted_password.hex()
"""

0 comments on commit e88482b

Please sign in to comment.