This page is READ-ONLY. It is generated from the old site.
All timestamps are relative to 2013 (when this page is generated).
If you are looking for TeX support, please go to VietTUG.org

ruby: encode64 string

Added by over 3 years ago

From ruby shell

Use ruby shell to get base64 encoded version of any string:

$ irb
> require 'rubygems'
=> true
> require 'activesupport'
=> true
> Base64.encode64("adsf")
=> "YWRzZg==\n" 
> Base64.encode64s("adsf")
=> "YWRzZg==" 

The function encode64s doesnot provide you the "\n" charater.

Script

Below the script (named base64.rb)

#!/usr/bin/ruby

require 'rubygems'
require 'activesupport'

ARGV.each do |st|
  est = Base64.encode64s(st)
  puts "#{st}\t=> #{est}" 
end

Example

$ time base64.rb foobar example.net
foobar  => Zm9vYmFy
example.net     => ZXhhbXBsZS5uZXQ=

real    0m0.249s
user    0m0.231s
sys     0m0.017s

Comments

Added by over 2 years ago

printf "foobar" | openssl enc -base64