vantage6.common.encryption.CryptorBase#

class CryptorBase(*args, **kwargs)#

Bases: object

Base class/interface for encryption implementations.

__init__()#

Create a new CryptorBase instance.

Methods

__init__()

Create a new CryptorBase instance.

bytes_to_str(data)

Encode bytes as base64 encoded string.

decrypt_str_to_bytes(data)

Decrypt base64 encoded string data.

encrypt_bytes_to_str(data, pubkey_base64)

Encrypt bytes in data using a (base64 encoded) public key.

str_to_bytes(data)

Decode base64 encoded string to bytes.

static bytes_to_str(data)#

Encode bytes as base64 encoded string.

Parameters:

data (bytes) – The data to encode.

Returns:

The base64 encoded string.

Return type:

str

decrypt_str_to_bytes(data)#

Decrypt base64 encoded string data.

Parameters:

data (str) – The data to decrypt.

Returns:

The decrypted data.

Return type:

bytes

encrypt_bytes_to_str(data, pubkey_base64)#

Encrypt bytes in data using a (base64 encoded) public key.

Note that the public key is ignored in this base class. If you want to encode your data with a public key, use the RSACryptor class.

Parameters:
  • data (bytes) – The data to encrypt.

  • pubkey_base64 (str) – The public key to use for encryption. This is ignored in this base class.

Returns:

The encrypted data encoded as base64 string.

Return type:

str

static str_to_bytes(data)#

Decode base64 encoded string to bytes.

Parameters:

data (str) – The base64 encoded string.

Returns:

The encoded string converted to bytes.

Return type:

bytes