I import an XML file as a byte array to the project
RandomAccessFile rnd = new RandomAccessFile(filePath, "r");
byte[] fileData = new byte[(int) rnd.length()];
rnd.read(fileData);
I encrypted the array using java.crypto
Cipher cipher = Cipher.getInstance("DESede/CBC/PKCS5Padding");
byte[] encypted = new byte[cipher.getOutputSize(fileData.length)];
int len = cipher.update(fileData, 0, fileData.length, encypted, 0);
len += cipher.doFinal(encypted, len);
When I decrypt the byte array and print it using
System.out.println(new String(decrypted, "UTF-8"));
I got the XML file but there were some unkown characters at the end (they are only at the end). Is there any way I can remove this?
Thanks in advance