Encryption Settings

class b2sdk.v2.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, or UNKNOWN_KEY_ID when that information is missing. The secret may be None, if encryption metadata is read from the server.

__init__(secret: Optional[bytes], key_id: Union[str, None, b2sdk.encryption.setting._UnknownKeyId])[source]
b2sdk.v2.UNKNOWN_KEY_ID

alias of _UnknownKeyId.unknown_key_id

class b2sdk.v2.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.v2.EncryptionMode) – encryption mode

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

  • key (b2sdk.v2.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'
}
v2.SSE_NONE = <EncryptionSetting(EncryptionMode.NONE, None, None)>

Commonly used “no encryption” setting

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

Commonly used SSE-B2 setting