Created
November 23, 2016 16:46
-
-
Save adamchainz/a967be11065c6037a4f8e1b40774bbca to your computer and use it in GitHub Desktop.
SES credentials hash
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
""" | |
Implements the algorithm at https://docs.aws.amazon.com/ses/latest/DeveloperGuide/smtp-credentials.html | |
""" | |
import hmac | |
import hashlib | |
import base64 | |
def ses_hash(secret_access_key): | |
message = "SendRawEmail" | |
version = 0x02 | |
signature = hmac.new( | |
key=secret_access_key, | |
msg=message, | |
digestmod=hashlib.sha256, | |
).digest() | |
signature_and_ver = b'\x02' + signature | |
password = base64.b64encode(signature_and_ver) | |
return password |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
A python version has since been added to the amazon doc https://docs.aws.amazon.com/ses/latest/DeveloperGuide/smtp-credentials.html#python