How to print the data in byte array as characters?

Well if you’re happy printing it in decimal, you could just make it positive by masking:

int positive = bytes[i] & 0xff;

If you’re printing out a hash though, it would be more conventional to use hex. There are plenty of other questions on Stack Overflow addressing converting binary data to a hex string in Java.

Leave a Comment