Last active
June 21, 2016 16:24
-
-
Save elyscape/645ca1853d8b4c77789e56b748c9f773 to your computer and use it in GitHub Desktop.
This script converts an AWS secret access key into an SMTP password for SES.
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
#!/usr/bin/env ruby | |
require 'openssl' | |
require 'base64' | |
require 'io/console' | |
VERSION = "\x02".force_encoding('BINARY').freeze | |
MESSAGE = 'SendRawEmail'.freeze | |
digest = OpenSSL::Digest.new('sha256') | |
print 'Please enter your secret access key: ' | |
key = nil | |
STDIN.noecho do | |
key = gets.chomp | |
end | |
puts | |
signature = OpenSSL::HMAC.digest(digest, key, MESSAGE) | |
signature_with_version = VERSION + signature | |
smtp_password = Base64.encode64(signature_with_version).chomp | |
puts smtp_password |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is based on the algorithm documented here.