blob: 6ded7b8cb9ca1c023a1801df089796d3647fe83b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
package com.keuin.kbackupfabric.util;
import java.nio.charset.StandardCharsets;
public class BytesUtil {
private static final byte[] HEX_ARRAY = "0123456789ABCDEF".getBytes(StandardCharsets.US_ASCII);
public static String bytesToHex(byte[] bytes) {
byte[] hexChars = new byte[bytes.length * 2];
for (int j = 0; j < bytes.length; j++) {
int v = bytes[j] & 0xFF;
hexChars[j * 2] = HEX_ARRAY[v >>> 4];
hexChars[j * 2 + 1] = HEX_ARRAY[v & 0x0F];
}
return new String(hexChars, StandardCharsets.UTF_8);
}
}
|