Skip to content

Instantly share code, notes, and snippets.

@katsuobushiFPGA
Created March 20, 2016 07:43
Show Gist options
  • Save katsuobushiFPGA/4fc83f7fd4d6f5ea6b97 to your computer and use it in GitHub Desktop.
Save katsuobushiFPGA/4fc83f7fd4d6f5ea6b97 to your computer and use it in GitHub Desktop.
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