Skip to content

Instantly share code, notes, and snippets.

@njofce
Created March 1, 2020 00:44
Show Gist options
  • Select an option

  • Save njofce/49194e3145f8fc5e029fe1b32187da74 to your computer and use it in GitHub Desktop.

Select an option

Save njofce/49194e3145f8fc5e029fe1b32187da74 to your computer and use it in GitHub Desktop.
import boto3
import base64
import hashlib
import os
s3 = boto3.resource("s3")
BUCKET_NAME="secure-cc"
def upload_file_with_encryption_key(file_path, key_path):
key_file = open(key_path, 'r')
key = key_file.read()
data = open(file_path, 'rb')
s3.Bucket(BUCKET_NAME).put_object(
Key='encrypted.txt',
Body=data,
SSECustomerAlgorithm='AES256',
SSECustomerKey=key
)
upload_file_with_encryption_key("simple_file.txt", "private_key.txt")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment