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);
}
Created
September 6, 2017 05:23
-
-
Save FoxIvan/63e3c3fb79b110be044b25bd9bc1855e 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
Here is kotlin version of the same for anyone ending here: