Frank Mitchell

Computing Base64 values on Windows

When you’re signing Amazon Web Service requests, one of the steps in the process is to Base64 encode the signature. On Linux you can do this with the base64 command. Since I haven’t found a Windows command line tool for computing Base64 values, I rolled my own in Ruby.

require 'base64'

data = ARGV[0]
if File.exists? data
  data = open(data, 'rb') { |io| io.read }
end
puts Base64.encode64(data)

Usage looks like:

ruby ~/base64.rb {value|file}

Like my tool for computing SHA-256 checksums its got no help, no options, and no error handling. I use it all the time.