My affine cipher will not decode every 5th and 6th letter correctly.... Please help. public class KeyGen { public void encrypt(ArrayList plainText, ArrayList cipherText) { for(int i = 0; i < plainText.size(); i++){ int ct = (int) plainText.get(i); ct = ((((ct-97) *5) +8)%26)+97; cipherText.add(ct); System.out.print((char)(int)cipherText.get(i)); } } public void decrypt(ArrayList cipherText, ArrayList decodedText){ for(int i = 0; i < cipherText.size(); i++){ int ct = (int) cipherText.get(i);
public class KeyGen { public void encrypt(ArrayList plainText, ArrayList cipherText) { for(int i = 0; i < plainText.size(); i++){ int ct = (int) plainText.get(i); ct = ((((ct-97) *5) +8)%26)+97; cipherText.add(ct); System.out.print((char)(int)cipherText.get(i)); } } public void decrypt(ArrayList cipherText, ArrayList decodedText){ for(int i = 0; i < cipherText.size(); i++){ int ct = (int) cipherText.get(i); ct = ct-97; ct = (abs((ct-8))*21 %26)+97; decodedText.add(ct); } }
Join our real-time social learning platform and learn together with your friends!