I am writing a UDP program to send byte[] to the host , i need to send a encrypted text ( RC4 ) to the host , whereby the host decrypt and get the plaintext but i met with some problems whereby where i convert char[] to byte[] to send to host , the host will decrypt the bytes by first convert it to string then get bytes.
String data = new String(RC4().toString().getBytes()); // Simulate host recieve bytes then i convert to string to convert to char[] for decryption.
char[] tester = data.toCharArray();
System.out.println("EN:"+RC4());// Display [C@6d06d69c
System.out.println(tester); // Display [C@6d06d69c
System.out.println(RC4D(tester)); // Display some gibberish.
System.out.println(RC4D(RC4())); // Display the correct plain text
Both RC4() encryption function and RC4D() decryption function returns char[] , i hardcode the msg to encrypt in RC4()
I don't get why both shows the same encrypted text but when i decrypt tester , the result differs from RC4().