Last active
August 10, 2018 04:57
-
-
Save w3iBStime/a26bd670bf7f98675674 to your computer and use it in GitHub Desktop.
Python script to derive AWS SES SMTP passwords from IAM access secret keys using HMAC, SHA256 and Base64 per http://docs.aws.amazon.com/ses/latest/DeveloperGuide/smtp-credentials.html
This file contains 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
import base64 | |
import hmac | |
import hashlib | |
secret = "_____" # replace with the secret key to be hashed | |
message = "SendRawEmail" | |
sig_bytes = bytearray(b'\x02') # init with version | |
theHmac = hmac.new(secret.encode("ASCII"), message.encode("ASCII"), hashlib.sha256) | |
the_hmac_hexdigest = theHmac.hexdigest() | |
sig_bytes.extend(bytearray.fromhex(the_hmac_hexdigest)) | |
print(base64.b64encode(sig_bytes)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment