lck.common 0.4.4 documentation

This Page

lck.crypto

lck.crypto

High-level cryptographic routines.

Factory functions

These are convenience routines that create Cipher instances with the correct algorithm implementation plugged in.

aes([key, path, create]) → Cipher instance

Factory creating a cipher using the AES algorithm. Arguments have the same meaning as in the raw Cipher class.

blowfish([key, path, create]) → Cipher instance

Factory creating a cipher using the Blowfish algorithm. Arguments have the same meaning as in the raw Cipher class.

cast([key, path, create]) → Cipher instance

Factory creating a cipher using the CAST algorithm. Arguments have the same meaning as in the raw Cipher class.

des([key, path, create]) → Cipher instance

Factory creating a cipher using the DES algorithm. Arguments have the same meaning as in the raw Cipher class.

des3([key, path, create]) → Cipher instance

Factory creating a cipher using the DES3 algorithm. Arguments have the same meaning as in the raw Cipher class.

Classes

class Cipher(key=None, path=None, create=True, cipher=None)

Using a provided key or path to a file with the key, create a Cipher capable of encrypting and decrypting bytes. cipher is the algorithm to be used.

If path is provided and create is True, if the file under path is absent, it is created.

encrypt(buffer, base64=False)

Encrypts the specified buffer, optionally encoding the result to Base64.

Note: only bytestrings can be encrypted directly. For Unicode strings, encode them to bytes first.

decrypt(buffer, base64=False)

Descrypt the specified buffer, optionally decoding from Base64 first.

Note: only bytestrings can be decrypted directly. For Unicode strings, encode them to bytes first.