Skip to content

Instantly share code, notes, and snippets.

@passcod
Created November 2, 2012 07:58
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 passcod/3999369 to your computer and use it in GitHub Desktop.
Save passcod/3999369 to your computer and use it in GitHub Desktop.
LOLcrypt Ruby
def lolcrypt(str, decrypt = false)
cipher = "aeoiubcdfghjklmnpqrstvwxyz"
str.split("").map { |t|
caps = /[A-Z]/ =~ t
t.downcase!
i = cipher.index t
if /[a-z]/ =~ t
t = cipher[ /[aeoiu]/ =~ t ? (decrypt ? i-2 : i+2)%5 : (decrypt ? i-15 : i+5)%21+5 ]
end
caps ? t.upcase : t
}.join ""
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment