Hi guys i have never used mod befopre and baiscally
i need the number to wrap around 1- 95 so if i have a sum 6-10 it would come round to +4 instead of -4 or if we have 27-30 its
I have this bit of code which is used to decrypt a vigniere cipher i use a vigenere square which is 95x95 and to decrypt it.
im trying to follow this formular :
P_i \equiv (C_i - K_i) \pmod {26}
Vigenère cipher - Wikipedia, the free encyclopedia
"Decryption is performed by going to the row in the table corresponding to the key, finding the position of the ciphertext letter in this row, and then using the column's label as the plaintext. For example, in row L (from LEMON), the ciphertext L appears in column A, which is the first plaintext letter. Next we go to row E (from LEMON), find the ciphertext X in column T, which is the second plaintext letter.
Vigenère can also be viewed algebraically. If the letters A–Z are taken to be the numbers 0–25, and addition is performed modulo 26, then Vigenère encryption can be written,"
for(int i=0; i<keyY.length; i++) { Ykey[i]= (keyY[i] - 32); //works out row Xcipher[i]= (cipherX[i] - 32); //work out coloum columnarray[i] =(Xcipher[i]-Ykey[i]+); // THIS IS THE bt where i need mod95 System.out.printf("%4s", columnarray[i]); }