I am performing xor encryption in Java. It encrypts a byte array, converts it into a String, and then prints the String.
However, when I execute it, I get strange "boxes" in the output (Eclipse console).
The algorithm code:
for(int i = 0; i < messageArr.length; i++)
{
encryptedMessage[i] = (byte) (messageArr[i]^codebookArr[i]);
}
String eMessage = new String(encryptedMessage);
return eMessage;
The main method:
String lMessage = e.xorEncrypt(message, codebook);
System.out.println("Encrypted message: " + lMessage);
String uMessage = e.xorEncrypt(lMessage, codebook);
System.out.println("Unencrypted message: " + uMessage);
When I run this code, it prints strange "boxes" for the encrypted string. However, when it decrypts the string, I receive the original output, showing that the encryption algorithm works.
Why do I receive the strange boxes for the encrypted output, but the correct string when I decrypt it?
messageandcodebook?