private final static char[] HEX_ARRAY = "0123456789ABCDEF".toCharArray();
public static String toHex(byte[] bytes) {
char[] hexChars = new char[bytes.length * 2];
for (int i = 0; i < bytes.length; i++) {
int byteValue = bytes[i] & 0xFF;
hexChars[i * 2] = HEX_ARRAY[byteValue >>> 4];
hexChars[i * 2 + 1] = HEX_ARRAY[byteValue & 0x0F];
}
return new String(hexChars);
}
-
-
Save darkstone/9ad68b3c96514755d1d01cbcc0cc9fa3 to your computer and use it in GitHub Desktop.
bytes to hex
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment