https://github.com/hupe1980/aws-s3-encryption-python
Client-side encryption for S3
https://github.com/hupe1980/aws-s3-encryption-python
aws client-side-encryption s3
Last synced: 2 months ago
JSON representation
Client-side encryption for S3
- Host: GitHub
- URL: https://github.com/hupe1980/aws-s3-encryption-python
- Owner: hupe1980
- License: mit
- Created: 2021-02-12T08:34:32.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2021-02-28T21:19:51.000Z (over 5 years ago)
- Last Synced: 2025-05-31T19:37:06.093Z (about 1 year ago)
- Topics: aws, client-side-encryption, s3
- Language: Python
- Homepage:
- Size: 32.2 KB
- Stars: 1
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.rst
- License: LICENSE
Awesome Lists containing this project
README
############################
S3 Encryption SDK for Python
############################
.. image:: https://img.shields.io/pypi/v/s3-encryption-sdk.svg
:target: https://pypi.python.org/pypi/s3-encryption-sdk
:alt: Latest Version
.. image:: https://img.shields.io/pypi/pyversions/s3-encryption-sdk.svg
:target: https://pypi.org/project/s3-encryption-sdk
:alt: Supported Python Versions
.. image:: https://github.com/hupe1980/aws-s3-encryption-python/workflows/ci/badge.svg
:target: https://github.com/hupe1980/aws-s3-encryption-python/actions?query=workflow%3Aci
:alt: 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.
.. code::
$ pip install s3-encryption-sdk
*****
Usage
*****
.. code-block:: python
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")
.. _cryptography: https://cryptography.io/en/latest/
.. _cryptography installation guide: https://cryptography.io/en/latest/installation.html
.. _GitHub: https://github.com/hupe1980/aws-s3-encryption-python/