Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 5 of 5

Thread: mod 95 vigninere cipher

  1. #1
    Member
    Join Date
    Oct 2010
    Posts
    61
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default 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,"


     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]);
     
          }
    Last edited by helloworld922; December 5th, 2010 at 05:36 PM.


  2. #2
    Member
    Join Date
    Oct 2010
    Posts
    61
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: mod 95 vigninere cipher

    i have had a look at various ways but i dont really understand how to use the %

  3. #3
    Super Moderator helloworld922's Avatar
    Join Date
    Jun 2009
    Posts
    2,896
    Thanks
    23
    Thanked 619 Times in 561 Posts
    Blog Entries
    18

    Default Re: mod 95 vigninere cipher

    Are you talking about the modulus operator (that's denoted by the % sign)?

    5 % 3; // performs "5 modulo 3", returns the remainder of 5/3, or 2.

  4. #4
    Member
    Join Date
    Oct 2010
    Posts
    61
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: mod 95 vigninere cipher

    well it says mod not sure if it can be done using modulus

  5. #5
    Super Moderator helloworld922's Avatar
    Join Date
    Jun 2009
    Posts
    2,896
    Thanks
    23
    Thanked 619 Times in 561 Posts
    Blog Entries
    18

    Default 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;

Similar Threads

  1. 2d (4x4) array insdie a 1d array. (Block cipher)
    By fortune2k in forum Collections and Generics
    Replies: 13
    Last Post: November 23rd, 2010, 05:29 PM
  2. Creating Block cipher without the use of inbuilt java funcs
    By fortune2k in forum Algorithms & Recursion
    Replies: 0
    Last Post: November 15th, 2010, 09:43 AM
  3. creating a ceaser cipher
    By fortune2k in forum Algorithms & Recursion
    Replies: 3
    Last Post: November 15th, 2010, 09:36 AM
  4. TCP chat attaching cipher is not running
    By Koren3 in forum Java Networking
    Replies: 4
    Last Post: May 19th, 2009, 02:52 AM
  5. [SOLVED] Interesting error cipher while sending message
    By Koren3 in forum Java Networking
    Replies: 0
    Last Post: April 29th, 2009, 09:54 AM