Created
February 13, 2018 08:39
-
-
Save MeLlamoPablo/4da48793139741dbdf61cddcc785af4f to your computer and use it in GitHub Desktop.
Node.js snippet that converts an AWS IAM secret access key to an AWS SES SMTP password
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
/* | |
* Implementation of the algorithm described here: | |
* https://docs.aws.amazon.com/ses/latest/DeveloperGuide/smtp-credentials.html | |
*/ | |
const {createHmac} = require("crypto"); | |
const key = process.env.KEY || (() => { throw new Error("Variable KEY not defined")} )(); | |
const msg = "SendRawEmail"; | |
const version = new Buffer(1); | |
version.writeUInt8(0x02, 0); | |
const signature = createHmac("sha256", key).update(msg).digest(); | |
const signatureAndVer = Buffer.concat([version, signature]); | |
console.log(signatureAndVer.toString("base64")); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment