SymmetricCipher Module¶
- class SymmetricCipher¶
A class for handling symmetric encryption.
- generate_key()¶
Generate a 256-bit symmetric key.
- Returns:
The generated symmetric key.
- Return type:
bytes
- generate_iv()¶
Generate a 128-bit initialization vector.
- Returns:
The generated initialization vector.
- Return type:
bytes
- aes_encrypt(key, iv, plaintext)¶
Encrypt a plaintext message using AES encryption.
- Parameters:
key (bytes) -- The symmetric key.
iv (bytes) -- The initialization vector.
plaintext (str) -- The plaintext message to be encrypted.
- Returns:
The encrypted message.
- Return type:
bytes
- aes_decrypt(key, iv, ciphertext)¶
Decrypt a ciphertext message using AES decryption.
- Parameters:
key (bytes) -- The symmetric key.
iv (bytes) -- The initialization vector.
ciphertext (bytes) -- The ciphertext message to be decrypted.
- Returns:
The decrypted message.
- Return type:
str