crandas.crypto

crandas.crypto.cipher.AES_128(key)

AES-128 cipher

Parameters:

key (bytes column) – AES-128 key as a crandas bytes column of 16 bytes. The number of rows in the column has to match the number of rows in the messages that will be encrypted. If the same key is used for all messages, use key.as_value().

Returns:

Cipher object for AES-128 initialized with the provided key

Return type:

Cipher

crandas.crypto.cipher.AES_192(key)

AES-192 cipher

Parameters:

key (bytes column) – AES-192 key as a crandas bytes column of 24 bytes. The number of rows in the column has to match the number of rows in the messages that will be encrypted. If the same key is used for all messages, use key.as_value().

Returns:

Cipher object for AES-192 initialized with the provided key

Return type:

Cipher

crandas.crypto.cipher.AES_256(key)

AES-256 cipher

Parameters:

key (bytes column) – AES-256 key as a crandas bytes column of 32 bytes. The number of rows in the column has to match the number of rows in the messages that will be encrypted. If the same key is used for all messages, use key.as_value().

Returns:

Cipher object for AES-256 initialized with the provided key

Return type:

Cipher

class crandas.crypto.cipher.Cipher(name, round_keys)

Bases: object

Cipher object, contains the round keys needed for encryption of a message using the encrypt method. Currently only AES-128, AES-192 and AES-256 are supported for 16 byte messages.

encrypt(message)

Encrypt the message given the round keys of the Cipher object

Parameters:

message (bytes column) – Message to be encrypted as a crandas bytes column. Byte length must be equal to the block size of the underlying cipher. For AES this is 16 bytes.

Returns:

Message encrypted with the key belonging to the Cipher

Return type:

bytes column