Publish a helper function to the API
This commit is contained in:
parent
7e5c273f4d
commit
bd9a99e78e
3 changed files with 17 additions and 2 deletions
15
src/main/java/dev/zontreck/libzontreck/util/BinUtil.java
Normal file
15
src/main/java/dev/zontreck/libzontreck/util/BinUtil.java
Normal file
|
@ -0,0 +1,15 @@
|
|||
package dev.zontreck.libzontreck.util;
|
||||
|
||||
public class BinUtil {
|
||||
private static final char[] HEX_ARRAY = "0123456789ABCDEF".toCharArray();
|
||||
|
||||
public static String bytesToHex(byte[] bytes) {
|
||||
char[] hexChars = new char[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);
|
||||
}
|
||||
}
|
Reference in a new issue