auxlib.crypt

wrapper around PyCrypto cryptography library

Information sources:
auxlib.crypt.as_base64(content)[source]
auxlib.crypt.from_base64(content)[source]
auxlib.crypt.encrypt(secret_key, data)[source]
auxlib.crypt.decrypt(secret_key, encryption_key_encrypted, encrypted_data)[source]
auxlib.crypt.aes_encrypt(base64_encryption_key, data)[source]

Encrypt data with AES-CBC and sign it with HMAC-SHA256

Parameters:
  • base64_encryption_key (str) – a base64-encoded string containing an AES encryption key and HMAC signing key as generated by generate_encryption_key()
  • data (str) – a byte string containing the data to be encrypted
Returns:

the encrypted data as a byte string with the HMAC signature appended to the end

Return type:

str

auxlib.crypt.aes_decrypt(base64_encryption_key, base64_data)[source]

Verify HMAC-SHA256 signature and decrypt data with AES-CBC

Parameters:
  • encryption_key (str) – a base64-encoded string containing an AES encryption key and HMAC signing key as generated by generate_encryption_key()
  • data (str) – a byte string containing the data decrypted with an HMAC signing key appended to the end
Returns:

a byte string containing the data that was originally encrypted

Return type:

str

Raises:

AuthenticationError – when the HMAC-SHA256 signature authentication fails