Tanji Module¶
- class Tanji(secret_key=None)¶
A class for handling symmetric and asymmetric encryption.
- secret_key¶
The secret key used for symmetric encryption.
- private_key¶
The private key used for asymmetric encryption.
- public_key¶
The public key used for asymmetric encryption.
- iv¶
The initialization vector used for symmetric encryption.
- generate_key_pair()¶
Generate a pair of private and public keys for asymmetric encryption.
- encrypt_message(message)¶
Encrypt a message using symmetric encryption, then encrypt the symmetric key using asymmetric encryption.
- Parameters:
message (str) -- The message to be encrypted.
- Returns:
The encrypted symmetric key and the encrypted message, both base64 encoded.
- Return type:
tuple
- decrypt_message(encrypted_sym_key, ciphertext)¶
Decrypt a symmetric key using asymmetric encryption, then decrypt a message using the decrypted symmetric key.
- Parameters:
encrypted_sym_key (str) -- The encrypted symmetric key, base64 encoded.
ciphertext (str) -- The encrypted message, base64 encoded.
- Returns:
The decrypted message.
- Return type:
str