public static String toHex(String str){ try { byte[] bytes = str.getBytes("GBK"); StringBuilder sb = new StringBuilder(bytes.length * 2); //转换hex编码 for (byte b : bytes) { sb.append(Integer.toHexString(b + 0x800).substring(1)); } return sb.toString(); } catch (UnsupportedEncodingException e) { log.error(e); } return null; }
时间: 2024-10-11 10:44:07