private static String byteToHex(byte[] bytes) { StringBuilder hex = new StringBuilder(); for (byte b : bytes) { hex.append(HEXES[(b >> 4) & 0x0f]); hex.append(HEXES[b & 0x0f]); } return hex.toString(); } public static byte[] hexStringToBytes(String str) { byte[] bs = new byte[str.length() / 2]; for (int i = 0; i < bs.length; i++) { bs[i] = (byte) Integer.parseInt(str.substring(i * 2, i * 2 + 2), 16); } return bs; }
标签:进制,16,二进制,hex,static,str,bs,byte From: https://www.cnblogs.com/zincredible/p/16749504.html