Created
March 20, 2011 16:01
-
-
Save JohnB/878409 to your computer and use it in GitHub Desktop.
Just a bit of fun...
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'base64' | |
class Object | |
def e64 str | |
Base64.encode64(str).chomp | |
end | |
def d64 str | |
Base64.decode64 str | |
end | |
def rot13 str | |
rotN(13,str) | |
end | |
def rotN n, str | |
n %= 26 | |
replace = ('A'.ord + n).chr + "-ZA-" + ('A'.ord + n - 1).chr | |
replace += replace.downcase | |
str.tr("A-Za-z", replace) | |
end | |
def i36 str | |
str.split(/\s+/).collect { |s| s.to_i(36) }.join(' ') | |
end | |
def s36 str | |
str.split(' ').collect { |t| t.to_i.to_s(36) }.join(' ') | |
end | |
end | |
"===== BEGIN HERE =====" | |
e64 "===== BEGIN HERE =====" | |
rot13 "===== BEGIN HERE =====" | |
i36 "===== BEGIN HERE =====" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment