Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Python Script to generate a policy and signature. Useful when using CORS uploads to S3.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import base64, hmac, sha
private_key = 'YOUR PRIVATE KEY'
input = open("policy.txt", "rb")
policy =
policy_encoded = base64.b64encode(policy)
signature = base64.b64encode(, policy_encoded, sha).digest())
print "Your policy base-64 encoded is %s." % (policy_encoded)
print "Your signature base-64 encoded is %s." % (signature)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment