oyouareatubeo

generate-policy-signature.py

Feb 14th, 2012
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.63 KB | None | 0 0
  1. #!/usr/bin/env python
  2.  
  3. p = """{"expiration": "2013-01-01T00:00:00Z",
  4.  "conditions": [
  5.    {"bucket": "sam-s3-test-64"},
  6.    ["starts-with", "$key", "upload-"],
  7.    {"acl": "private"},
  8.    ["starts-with", "$Content-Type", ""],
  9.    ["starts-with", "$redirect", ""],
  10.    ["starts-with", "$x-archive-auto-make-bucket", ""],
  11.    ["starts-with", "$x-archive-queue-derive", ""],
  12.    ["content-length-range", 0, 1048576]
  13.  ]
  14. }"""
  15.  
  16. # secret key
  17. s = "seCr3tk3y"
  18.  
  19. import base64
  20. import hmac, sha
  21.  
  22. policy = base64.b64encode(p)
  23.  
  24. signature = base64.b64encode(
  25.     hmac.new(s, policy, sha).digest())
  26.  
  27.  
  28. print policy
  29. print signature
Advertisement
Add Comment
Please, Sign In to add comment