I am converting a byte[] array to string . And then converting the string back to byte[] array. Then on checking if both the arrays are equal - I get that they are not equal:
byte[] ciphertext2=c.doFinal(username.getBytes("utf-8"));
//JUST CHECKING IGNORE
String qaz=new String(ciphertext2,"utf-8");
//qaz=qaz+"1";
System.out.println("just chekcing------------------------"+qaz);
byte[] ciphertext3=qaz.getBytes("utf-8");
if(Arrays.equals(ciphertext2,ciphertext3))
{
System.out.println("just chekcing they are equal------------------------");
}
else
System.out.println("just chekcing they are not equal------------------------");<br>
OUTPUT :
just chekcing they are not equal--------------------
Why doesn't it work?
Edit
It works perfectly fine when using Base64 of java. But why doesn't it work when converting byte to string and vice-versa directly? What actually happens when you convert a string a byte array and vice versa?