Ask your own question, for FREE!
Mathematics 15 Online
OpenStudy (hyroko):

I am having trouble with my affine caesar cipher decoding. I'm taking ascii values, subtracting 97 to get 0-25, applying the shift, then adding 97 back to get the cipher text, and that encodes just fine. But my decoding is getting a wrong output every 5th and 6th number, and I'm not sure why.

OpenStudy (hyroko):

Here is the code 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); } } }

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!