Item Encryptor
Top-level functions for encrypting and decrypting DynamoDB items.
- dynamodb_encryption_sdk.encrypted.item.encrypt_dynamodb_item(item: Dict[str, Dict[str, Any]], crypto_config: dynamodb_encryption_sdk.encrypted.CryptoConfig) Dict[str, Dict[str, Any]] [source]
Encrypt a DynamoDB item.
>>> from dynamodb_encryption_sdk.encrypted.item import encrypt_dynamodb_item >>> plaintext_item = { ... 'some': {'S': 'data'}, ... 'more': {'N': '5'} ... } >>> encrypted_item = encrypt_dynamodb_item( ... item=plaintext_item, ... crypto_config=my_crypto_config ... )
Note
This handles DynamoDB-formatted items and is for use with the boto3 DynamoDB client.
- Parameters
item (dict) – Plaintext DynamoDB item
crypto_config (CryptoConfig) – Cryptographic configuration
- Returns
Encrypted and signed DynamoDB item
- Return type
- dynamodb_encryption_sdk.encrypted.item.encrypt_python_item(item: Dict[str, Dict[str, Any]], crypto_config: dynamodb_encryption_sdk.encrypted.CryptoConfig) Dict[str, Dict[str, Any]] [source]
Encrypt a dictionary for DynamoDB.
>>> from dynamodb_encryption_sdk.encrypted.item import encrypt_python_item >>> plaintext_item = { ... 'some': 'data', ... 'more': 5 ... } >>> encrypted_item = encrypt_python_item( ... item=plaintext_item, ... crypto_config=my_crypto_config ... )
Note
This handles human-friendly dictionaries and is for use with the boto3 DynamoDB service or table resource.
- Parameters
item (dict) – Plaintext dictionary
crypto_config (CryptoConfig) – Cryptographic configuration
- Returns
Encrypted and signed dictionary
- Return type
- dynamodb_encryption_sdk.encrypted.item.decrypt_dynamodb_item(item: Dict[str, Dict[str, Any]], crypto_config: dynamodb_encryption_sdk.encrypted.CryptoConfig) Dict[str, Dict[str, Any]] [source]
Decrypt a DynamoDB item.
>>> from dynamodb_encryption_sdk.encrypted.item import decrypt_python_item >>> encrypted_item = { ... 'some': {'B': b'ENCRYPTED_DATA'}, ... 'more': {'B': b'ENCRYPTED_DATA'} ... } >>> decrypted_item = decrypt_python_item( ... item=encrypted_item, ... crypto_config=my_crypto_config ... )
Note
This handles DynamoDB-formatted items and is for use with the boto3 DynamoDB client.
- Parameters
item (dict) – Encrypted and signed DynamoDB item
crypto_config (CryptoConfig) – Cryptographic configuration
- Returns
Plaintext DynamoDB item
- Return type
- dynamodb_encryption_sdk.encrypted.item.decrypt_python_item(item: Dict[str, Dict[str, Any]], crypto_config: dynamodb_encryption_sdk.encrypted.CryptoConfig) Dict[str, Dict[str, Any]] [source]
Decrypt a dictionary for DynamoDB.
>>> from dynamodb_encryption_sdk.encrypted.item import decrypt_python_item >>> encrypted_item = { ... 'some': Binary(b'ENCRYPTED_DATA'), ... 'more': Binary(b'ENCRYPTED_DATA') ... } >>> decrypted_item = decrypt_python_item( ... item=encrypted_item, ... crypto_config=my_crypto_config ... )
Note
This handles human-friendly dictionaries and is for use with the boto3 DynamoDB service or table resource.
- Parameters
item (dict) – Encrypted and signed dictionary
crypto_config (CryptoConfig) – Cryptographic configuration
- Returns
Plaintext dictionary
- Return type