Skip to content

Instantly share code, notes, and snippets.

@UnquietCode
Created August 16, 2017 21:09
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 UnquietCode/b0840638daeefa3ace36d550b80ff78f to your computer and use it in GitHub Desktop.
Save UnquietCode/b0840638daeefa3ace36d550b80ff78f to your computer and use it in GitHub Desktop.
generate AWS SES email credentials in Python
# based on:
# https://charleslavery.com/notes/aws-ses-smtp-password-from-secret-key-python.html
import hashlib
import hmac
import base64
key = bytes('aws-secret-access-key').encode('utf-8')
message = bytes('SendRawEmail').encode('utf-8')
versionInBytes = bytes('\x02')
signatureInBytes = hmac.new(key, message, digestmod=hashlib.sha256).digest()
signatureAndVer = versionInBytes + signatureInBytes
smtpPassword = base64.b64encode(signatureAndVer)
print(smtpPassword)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment