For a course several years ago, I wrote a compact/efficient implementation of a Vigenere cipher:
private static char encipherCharacter(char message_char, char key_char){
return (char)(((int)(message_char) + (int)(key_char) - 194)%26 + 97);
}
public static String encipher(String plaintext, String key){
String ciphertext = "";
for(int i = 0; i < plaintext.length(); i++)
ciphertext += encipherCharacter(plaintext.charAt(i), key.charAt((i % key.length())));
return ciphertext;
}
I'd love to see other implementations, if anyone has some to share.https://gist.github.com/ctrezevant/8ca9e163d702af245ded35d97...