# symmetric cipher help

• 11-19-2009, 08:03 PM
George Lucas
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;
}
}
• 12-27-2011, 10:07 PM
Isaac93
Re: symmetric cipher help
I cant understand the program clearly can you please upload the symmetric class. Thank you.
• 12-27-2011, 10:21 PM
Fubarable
Re: symmetric cipher help