Encryption Settings

class b2sdk.v1.EncryptionKey[source]

Hold information about encryption key: the key itself, and its id. The id may be None, if it’s not set in encrypted file’s fileInfo. The secret may be None, if encryption metadata is read from the server.

__init__(secret: Optional[bytes], key_id: Optional[str])[source]

Initialize self. See help(type(self)) for accurate signature.

class b2sdk.v1.EncryptionSetting[source]

Hold information about encryption mode, algorithm and key (for bucket default, file version info or even upload)

__init__(mode: b2sdk.encryption.types.EncryptionMode, algorithm: Optional[b2sdk.encryption.types.EncryptionAlgorithm] = None, key: Optional[b2sdk.encryption.setting.EncryptionKey] = None)[source]
Parameters
  • mode (b2sdk.v1.EncryptionMode) – encryption mode

  • algorithm (b2sdk.v1.EncryptionAlgorithm) – encryption algorithm

  • key (b2sdk.v1.EncryptionKey) – encryption key object for SSE-C

as_dict()[source]

Represent the setting as a dict, for example:

{
    'mode': 'SSE-C',
    'algorithm': 'AES256',
    'customerKey': 'U3hWbVlxM3Q2djl5JEImRSlIQE1jUWZUalduWnI0dTc=',
    'customerKeyMd5': 'SWx9GFv5BTT1jdwf48Bx+Q=='
}
{
    'mode': 'SSE-B2',
    'algorithm': 'AES256'
}

or

{
    'mode': 'none'
}
v1.SSE_NONE = <EncryptionSetting(EncryptionMode.NONE, None, None)>

Commonly used “no encryption” setting

v1.SSE_B2_AES = <EncryptionSetting(EncryptionMode.SSE_B2, EncryptionAlgorithm.AES256, None)>

Commonly used SSE-B2 setting