Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
This script converts an AWS secret access key into an SMTP password for SES.
#!/usr/bin/env ruby
require 'openssl'
require 'base64'
require 'io/console'
VERSION = "\x02".force_encoding('BINARY').freeze
MESSAGE = 'SendRawEmail'.freeze
digest ='sha256')
print 'Please enter your secret access key: '
key = nil
STDIN.noecho do
key = gets.chomp
signature = OpenSSL::HMAC.digest(digest, key, MESSAGE)
signature_with_version = VERSION + signature
smtp_password = Base64.encode64(signature_with_version).chomp
puts smtp_password

This comment has been minimized.

Copy link
Owner Author

commented Jun 21, 2016

This is based on the algorithm documented here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.