1个byte对应8个bit,16进制使用4个bit,所以一个byte转成16进制,占用两位。JAVA代码private static final char HexCharArr[] = {'0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f'}; private static final String HexStr = "0123456789abcdef"; //字节数组转成16...
1/**2* 将字符串转为指定编码的16进制3*4*@paramstr5*@return6*/7publicstaticString encode(String str)throwsException {8String hexString = "0123456789ABCDEF";9//根据编码获取字节数组10byte[] bytes = str.getBytes("GBK");11StringBuilder sb =newStringBuilder(bytes.length * 2);12//将字节数组中...
string s = "02-56-00-FF-FF-0B-4F-21-14-A2-1C-D5-4C-37-9B-CD"; string[] ss = s.Split('-'); byte[] b = new byte[ss.Length]; for (int i = 0; i < ss.Length; i++) { b[i] = (byte)Convert.ToInt32(ss[i], 16); }...