Skip to main content

S3 Encryption Client for Python

Project description

Latest Version Supported Python Versions ci

Client-side encryption for S3

You can find the source on GitHub.

Getting Started

Required Prerequisites

  • Python 3.6+

Installation

Note

If you have not already installed cryptography, you might need to install additional prerequisites as detailed in the cryptography installation guide for your operating system.

$ pip install s3-encryption-sdk

Usage

import boto3
from s3_encryption_sdk import EncryptedClient
from s3_encryption_sdk.materials_providers import KmsMaterialsProvider


materials_provider = KmsMaterialsProvider(
   key_id="alias/YourAlias",
   client=boto3.client("kms", region_name="us-east-1"),
)

s3 = boto3.client("s3", region_name="us-east-1")

crypto_s3 = EncryptedClient(
   client=s3,
   materials_provider=materials_provider,
)

key = "4711"
plaintext = "foo bar"

crypto_s3.put_object(
   Bucket=bucket.name,
   Key=key,
   Body=plaintext,
)

encrypted_obj = s3.get_object(
   Bucket=bucket.name,
   Key="object",
)

decrypted_obj = crypto_s3.get_object(
   Bucket=bucket.name,
   Key="object",
)

assert plaintext != encrypted_obj["Body"].read().decode("utf8")
assert plaintext == decrypted_obj["Body"].read().decode("utf8")

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for s3-encryption-sdk, version 0.0.3
Filename, size File type Python version Upload date Hashes
Filename, size s3_encryption_sdk-0.0.3-py2.py3-none-any.whl (16.6 kB) File type Wheel Python version py2.py3 Upload date Hashes View
Filename, size s3-encryption-sdk-0.0.3.tar.gz (9.3 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page