2 ms·
A practical demonstration of this BTW (in scala): def otp(s: String, key: String): String = { def base64decode(s: String): String = { new String(ne
by harryh 14y ago
A practical demonstration of this BTW (in scala):
def otp(s: String, key: String): String = {
def base64decode(s: String): String = {
new String(new sun.misc.BASE64Decoder().decodeBuffer(s))
}
def xor(a: Char, b: Char): Char = (a ^ b).toChar
val s2 = base64decode(s)
val k2 = base64decode(key)
val sb = new StringBuilder()
for (i <- 0 to s2.length - 1) {
sb.append(xor(s2(i), k2(i)))
}
sb.toString
}
val ciphertext = "LQcGRC0HFR4ME0sjHhkOHBVSGB0ZGhIcWRUPQgsNFkYIHwdE"
val key1 = "YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXphYmNkZWZnaGlq"
val key2 = "eW9jZF5vemoscCpOezlobno/OGlxfzJ7K3R8MXItfShnaGtq"
otp(ciphertext, key1)
otp(ciphertext, key2)
So releasing the ciphertext into the wild accomplishes nothing.