#!/usr/bin/env python3 """ SES SMTP Password Converter A user's SMTP username is the same as their AWS Access Key ID, their password is generated by passing the private key through this algorithm. See the page below for further documentation. https://docs.aws.amazon.com/ses/latest/DeveloperGuide/smtp-credentials.html """ import sys import hmac import base64 import hashlib VERSION = b"\x02" MESSAGE = b"SendRawEmail" key = sys.argv[1].encode("us-ascii") mac = hmac.new(key, digestmod=hashlib.sha256) mac.update(MESSAGE) hash = mac.digest() print(base64.b64encode(VERSION + hash).decode("us-ascii"))