79793575

Date: 2025-10-18 05:50:03
Score: 1.5
Natty:
Report link

@Topaco in the first comment got the right answer. When you apply operations to data, its important to remember your order of operations.

In decrypt_data(), unpadding may only take place after decryption!

    @staticmethod
    def decrypt_data(password, salt, encrypted_data):
        print(f"{password=}")
        print(f"{salt=}")
        print("Encrypted Data: ")
        print(f"{encrypted_data}")
        key = PasswordManager.generate_aes_key(password, salt)
        print(f"{key=}")
        cipher = Cipher(algorithms.AES(key), modes.CBC(salt))
        decryptor = cipher.decryptor()
        decrypted_data = decryptor.update(encrypted_data) + decryptor.finalize()
        original_data = PasswordManager.unpad_data(decrypted_data)
        print(original_data)
        return original_data.decode(PasswordManager.encoding)
Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • User mentioned (1): @Topaco
  • Self-answer (0.5):
  • Low reputation (1):
Posted by: Dont worry about it