Last active
August 29, 2015 14:25
-
-
Save rbobillot/6a1483d7425ddeca1c75 to your computer and use it in GitHub Desktop.
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
object LeetCrypt | |
{ | |
implicit class Encrypt( src:String ) | |
{ | |
def leetOfString( s:String ) = { | |
s.map( | |
c => c match { | |
case 'a' | 'A' => '4' | |
case 'b' => '6' | |
case 'B' => '8' | |
case 'e' | 'E' => '3' | |
case 'g' => '9' | |
case 'l' | 'L' => '1' | |
case 'o' | 'O' => '0' | |
case 's' | 'S' => '5' | |
case 't' | 'T' => '7' | |
case _ => c | |
} | |
) | |
} | |
def stringOfLeet( s:String ) = { | |
s.map( | |
c => c match { | |
case '4' => 'a' | |
case '6' => 'b' | |
case '8' => 'B' | |
case '3' => 'e' | |
case '9' => 'g' | |
case '1' => 'l' | |
case '0' => 'o' | |
case '5' => 's' | |
case '7' => 't' | |
case _ => c | |
} | |
) | |
} | |
def toLeet = leetOfString( src ) | |
def fromLeet = stringOfLeet( src ) | |
} | |
def main( av:Array[String] ) = { | |
lazy val crypt = av(0).toLeet | |
lazy val origin = crypt.fromLeet | |
av.size match { | |
case 1 => | |
println( "L33t: " + crypt ) | |
println( "Plain: " + origin ) | |
case _ => | |
println( "Please give one argument to encrypt/decrypt" ) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Very basic l33t convertor, in Scala
Damn, I love Scala <3