Anonymous user
Playfair cipher: Difference between revisions
→{{header|Kotlin}}
(Added Kotlin) |
|||
Line 878:
}
class Playfair(
private val table: Array<CharArray> = Array(5, { CharArray(5) }) // 5 x 5 char array
Line 943:
}
val cleanText = getCleanText(plainText)
var cipherText = ""
for (i in 0 until length step 2) {
val (row1, col1) = findChar(cleanText[i])
Line 960:
}
var decodedText = ""
for (i in 0 until length step 3) { // cipherText will include spaces so we need to skip them
val (row1, col1) = findChar(cipherText[i])
Line 971:
else -> table[row1][col2].toString() + table[row2][col1]
}
if (i < length - 1) decodedText += " "
}
return decodedText
}
println("The table to be used is :\n")
for (i in 0..4) {
|