Created
November 2, 2012 07:58
-
-
Save passcod/3999369 to your computer and use it in GitHub Desktop.
LOLcrypt Ruby
This file contains 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
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