Class reference

This is the complete class reference for this project

Class CryptoParams

This is the class that allows the encryption and decryption of string using AES algorithm:

class cryptoparams.CryptoParams(key=None, iv=None)[source]

Provide encryption and decryption function for strings that use AES symmetric algorithm with CBC (which is compatible with crypto-js).

Padding implemented as per RFC 2315 PKCS#7 page 21

First base implementation for this class is taken from marcoslin gist.

Parameters:
  • key (str) – 32 bytes hexadecimal key used to initialize AES algorithm
  • iv (str) – 32 bytes hexadecimal initialization vector used to initialize AES algorithm
Raises ValueError:
 

if parameters are incorrect

decrypt(value)[source]

Decrypt a Base64 string using AES algorithm (CFB mode)

Parameters:value (str) – Base64 String to decrypt
Returns:String that represent the decrypted data with AES algorithm
Return type:str
encrypt(value)[source]

Encrypt a string using AES algorithm (CFB mode) and encode the result in Base64 to handle it easily

Parameters:value (str) – String to encrypt
Returns:Base64 String that represent the binary data encrypted with AES algorithm
Return type:str
iv

Initialization vector used by this class

Returns:32 bytes hexadecimal string containing the initialization vector used by the class
Return type:str
Raises ValueError:
 if invalid key is provided
key

AES Key used by the class

Returns:32 bytes hexadecimal string representing the key used by the class
Return type:str
Raises ValueError:
 if invalid key is provided