字节数组转16进制 @param bytes 需要转换的byte数组 @return 转换后的Hex字符串
(byte[] bytes)
| 58 | * @return 转换后的Hex字符串 |
| 59 | */ |
| 60 | public static String bytesToHex(byte[] bytes) { |
| 61 | StringBuffer sb = new StringBuffer(); |
| 62 | for(int i = 0; i < bytes.length; i++) { |
| 63 | String hex = Integer.toHexString(bytes[i] & 0xFF); |
| 64 | if(hex.length() < 2){ |
| 65 | sb.append(0); |
| 66 | } |
| 67 | sb.append(hex); |
| 68 | } |
| 69 | return sb.toString(); |
| 70 | } |
| 71 | |
| 72 | /** |
| 73 | * hex字符串转byte数组 |
nothing calls this directly
no outgoing calls
no test coverage detected