mod 95 vigninere cipher

• December 5th, 2010, 04:16 PM
fortune2k
mod 95 vigninere cipher
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,"

Code :

 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]);   }
• December 5th, 2010, 04:28 PM
fortune2k
Re: mod 95 vigninere cipher
i have had a look at various ways but i dont really understand how to use the %
• December 5th, 2010, 04:37 PM
helloworld922
Re: mod 95 vigninere cipher
Are you talking about the modulus operator (that's denoted by the % sign)?

Code Java:

5 % 3; // performs "5 modulo 3", returns the remainder of 5/3, or 2.
• December 5th, 2010, 05:31 PM
fortune2k
Re: mod 95 vigninere cipher
well it says mod not sure if it can be done using modulus
• December 5th, 2010, 08:43 PM
helloworld922
Re: mod 95 vigninere cipher
Normally in computer science mod is the short way of saying modulus (or modulo, depending on the conjugation), and in Java this is denoted with the % operator.

A modulo operation will naturally limit you to a range [0,x) (where x is the divisor, using set inclusion/exclusion notation).

So if you wanted a range [1, 95], you can translate this to num % 95 + 1;