When acquiring or processing binaries stored in the data store with Python and Java (Scala) In both cases, the way bytes are displayed is different and the comparison is troublesome, so I investigated how to display them in the same way.
Python
print(b"abcde".hex())
Java In println, the contents of byte [] cannot be displayed, and if you display each element with a for statement, it will be signed unlike Python, so it was quite troublesome, but you can display it in the same way below.
import java.math.BigInteger;
byte[] bytes = "abcde".getBytes();
System.out.printf("%x%n", new BigInteger(1, bytes));
Both are output as shown below.
6162636465
Recommended Posts