Skip to content

Instantly share code, notes, and snippets.

@mikepatrick
Created December 10, 2017 17:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mikepatrick/fca1e977501827a76ef7d5bf5242bf05 to your computer and use it in GitHub Desktop.
Save mikepatrick/fca1e977501827a76ef7d5bf5242bf05 to your computer and use it in GitHub Desktop.
import hmac, hashlib
#http://docs.aws.amazon.com/general/latest/gr//sigv4-calculate-signature.html
DateKey = hmac.new(b'AWS4wJalrXUtnFEMI/K7MDENG+bPxRfiCYEXAMPLEKEY', b'20150830', hashlib.sha256).digest()
print("kdate: " + hmac.new(b'AWS4wJalrXUtnFEMI/K7MDENG+bPxRfiCYEXAMPLEKEY', b'20150830', hashlib.sha256).hexdigest())
DateRegionKey = hmac.new(DateKey, b'us-east-1', hashlib.sha256).digest()
print("kRegion: " + hmac.new(DateKey, b'us-east-1', hashlib.sha256).hexdigest())
DateRegionServiceKey = hmac.new(DateRegionKey, b'iam', hashlib.sha256).digest()
print('kService: ' + hmac.new(DateRegionKey, b'iam', hashlib.sha256).hexdigest())
SigningKey = hmac.new(DateRegionServiceKey, b'aws4_request', hashlib.sha256).digest()
print('kSigning: ' + hmac.new(DateRegionServiceKey, b'aws4_request', hashlib.sha256).hexdigest())
string_to_sign = '''AWS4-HMAC-SHA256
20150830T123600Z
20150830/us-east-1/iam/aws4_request
f536975d06c0309214f805bb90ccff089219ecd68b2577efef23edd43b7e1a59'''
signature = hmac.new(SigningKey, string_to_sign, hashlib.sha256).hexdigest()
print('signature: ' + signature)
@itrustgod
Copy link

hey i dont know code but need this added to my javascript can anyone help me im willing to pay contact me ontime24seven@gmail.com

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment