| |
Methods defined here:
- __init__(self, key)
- Initializes the Crypto class with the given key.
Args:
key (str): The base64 encoded key used for encryption and decryption.
Attributes:
key (bytes): The decoded key used for encryption and decryption.
backend (object): The backend used for cryptographic operations.
block_size (int): The block size for the AES algorithm in bytes.
- decrypt(self, token)
- Decrypts the given token using AES encryption in CBC mode.
Args:
token (str): The base64 encoded string to be decrypted.
Returns:
str: The decrypted data as a string.
- encrypt(self, data)
- Encrypts the provided data using AES encryption with CBC mode and PKCS7 padding.
Args:
data (str): The plaintext data to be encrypted.
Returns:
str: The encrypted data encoded in URL-safe base64 format.
Static methods defined here:
- generate_key()
- Generates a secure random key.
This function generates a 32-byte secure random key and encodes it using URL-safe Base64 encoding.
Returns:
str: A URL-safe Base64 encoded string representing the secure random key.
Data descriptors defined here:
- __dict__
- dictionary for instance variables
- __weakref__
- list of weak references to the object
|