Add simple hex utils that delegate to Netty

The goal is to use libraries for this sort of common stuff
This commit is contained in:
P0nk
2021-07-15 23:48:47 +02:00
parent cce85ea663
commit 12a415e3d5
2 changed files with 33 additions and 0 deletions

View File

@@ -22,6 +22,7 @@
package tools;
import constants.string.CharsetConstants;
import io.netty.buffer.ByteBufUtil;
import java.io.ByteArrayOutputStream;
@@ -105,4 +106,14 @@ public class HexTool {
return "";
}
/**
* Get upper case hex dump
*/
public static String bytesToHex(byte[] bytes) {
return ByteBufUtil.hexDump(bytes).toUpperCase();
}
public static byte[] hexToBytes(String hex) {
return ByteBufUtil.decodeHexDump(hex);
}
}