aldy120 / s3-note

Note for Amazon S3
0 stars 0 forks source link

Use sse-c encryption in S3 #27

Open aldy120 opened 3 years ago

aldy120 commented 3 years ago
import base64
import os

def generate_encryption_key():
    """Generates a 256 bit (32 byte) AES encryption key and prints the
    base64 representation.

    This is included for demonstration purposes. You should generate your own
    key. Please remember that encryption keys should be handled with a
    comprehensive security policy.
    """
    key = os.urandom(32)
    encoded_key = base64.b64encode(key).decode("utf-8")

    print("Base 64 encoded encryption key: {}".format(encoded_key))

Decode the base64 and save it in a file.

aws s3 cp index.html s3://<BUCKET> --sse-c --sse-c-key fileb://key