Created
March 20, 2016 07:43
-
-
Save katsuobushiFPGA/4fc83f7fd4d6f5ea6b97 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 Main extends App{ | |
val str = "EBG KVVV vf n fvzcyr yrggre fhofgvghgvba pvcure gung ercynprf n yrggre jvgu gur yrggre KVVV yrggref nsgre vg va gur nycunorg. EBG KVVV vf na rknzcyr bs gur Pnrfne pvcure, qrirybcrq va napvrag Ebzr. Synt vf SYNTFjmtkOWFNZdjkkNH. Vafreg na haqrefpber vzzrqvngryl nsgre SYNT." | |
val flag = "FLAG" | |
for(i <- 0 until 26) { | |
if(str.contains(cipher(flag,i)) ) { | |
println(cipher(flag,i)) | |
println("key:" + i ) | |
} | |
} | |
println(str,13) | |
def cipher(plain:String,key:Int) : String = { | |
val count = plain.length | |
var res = | |
for(i <- plain) yield { | |
val r = | |
if((i.toInt + key) > 90) { | |
(i.toInt + key) - 26 | |
} | |
else { | |
(i.toInt + key) | |
} | |
r.toChar | |
} | |
res.mkString | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment