Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
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"
require 'base64'
based = Base64.encode64 ARGV[0]
if !ARGV[1].nil? && ARGV[1] == 'sep'
puts 'encoded-' + based.scan(/.{1}/).join('-')
puts based
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment