Created
September 26, 2013 18:38
-
-
Save stephenhowells/6718627 to your computer and use it in GitHub Desktop.
Python Script to generate a policy and signature. Useful when using CORS uploads to S3.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
import base64, hmac, sha | |
private_key = 'YOUR PRIVATE KEY' | |
input = open("policy.txt", "rb") | |
policy = input.read() | |
policy_encoded = base64.b64encode(policy) | |
signature = base64.b64encode(hmac.new(private_key, 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