score:1

i will speak to the java side; i believe the same comments apply to the c version as well.

you do not want to take your encrypted byte array and convert it to a string. in particular, here:

byte[] encvalue = cipher.dofinal(valuetoenc.getbytes());
return new string(encvalue);

the problem is that new string(byte[] b) is going to interpret the byte array as a string that is encoded with the default encoding. of course, the byte array is not an encoded string, so this isn't particularly useful.

if you want to get a string that you can use to compare the encrypted byte arrays (visually), the typical approach is to hex-encode the byte array. see how to convert a byte array to a hex string in java? and how do you convert buffer (byte array) to hex string in c? for more information. there are, of course, many libraries that support this functionality.


Related Query

More Query from same tag