Both string.getByte () and Hex.decodeHex (string.toCharaArray ()) are processes that convert a string string to byte [] type, but there are some differences.
string.getByte() Converts an ordinary character string to byte [] type. The byte length after conversion is twice the byte length when converted with hex.
Hex.decodeHex(string.toCharaArray()) Converts a character string with double quotes added to a hexadecimal number (in short, a string type but the content data is a hexadecimal number) to a byte type.
Then, what happens if the character string to be converted is a hexadecimal number such as "1" or "a", an ordinary character, or a character string that is seemingly indistinguishable?
As a result, different byte [] type strings are generated for each.
Recommended Posts