Skip to content

Instantly share code, notes, and snippets.

@mweppler
Created April 29, 2014 16:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mweppler/11405280 to your computer and use it in GitHub Desktop.
Save mweppler/11405280 to your computer and use it in GitHub Desktop.
Base 64 encode a string at the command line via ruby.
#!/usr/bin/env ruby
if ARGV[0].nil?
raise "Expecting a string as the first argument"
end
require 'base64'
based = Base64.encode64 ARGV[0]
if !ARGV[1].nil? && ARGV[1] == 'sep'
puts 'encoded-' + based.scan(/.{1}/).join('-')
else
puts based
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment