Results 1 to 3 of 3
  1. #1
    George Lucas is offline Member
    Join Date
    Nov 2009
    Posts
    1
    Rep Power
    0

    Default symmetric cipher help

    i'm not sure where to go from here on my symmetric cipher program. i'm trying to use the "key" to encrypt "msg" with an XOR(^) to write an array like msg2. right now, the program writes this:
    byte[] msg2 = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 ,0,0,0,0,0,0,0,0,0,0,0,};

    for example, xor the character codes for 'h' and 'd'; h^d == 12

    public class symmetric {

    public static void main(String args[]) {
    String key = "helloworld";
    String msg = "random text of awesomeness";
    byte[] msg2 = {11,10,0,0,10,16,10,82,3,2,72,4,28,28,3,30,10,22,7 6,23,11,12,9,2,12,18,};

    byte[] out = symmetric.crypt(key, msg.getBytes());
    System.out.print("byte[] msg2 = {");
    for (int i = 0; i < out.length; i++)
    System.out.print(out[i]+",");
    System.out.println("};");
    out = symmetric.crypt(key, msg2);
    String str = "";
    for (int i = 0; i < out.length; i++)
    str += (char)out[i];
    System.out.println(str);
    }

    public static byte [] crypt(String key, byte[] msg) {
    byte[] out = new byte[msg.length];

    return out;
    }
    }

  2. #2
    Isaac93 is offline Member
    Join Date
    Dec 2011
    Location
    Malta
    Posts
    6
    Rep Power
    0

    Default Re: symmetric cipher help

    I cant understand the program clearly can you please upload the symmetric class. Thank you.

  3. #3
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

Similar Threads

  1. vigenere cipher
    By swaart in forum New To Java
    Replies: 7
    Last Post: 11-22-2011, 07:20 PM
  2. How to cipher a string without using Cipher class?
    By arnab321 in forum New To Java
    Replies: 1
    Last Post: 09-08-2009, 11:19 PM
  3. Need help with Ceasar Cipher question
    By Gigi in forum New To Java
    Replies: 3
    Last Post: 01-21-2009, 03:25 AM
  4. cipher.. Won't work
    By jgonzalez14 in forum New To Java
    Replies: 1
    Last Post: 11-18-2008, 01:22 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •