package com.util; /** * ASCII与16进制互转 * * @author cyw * @time 2018-08-14 * */ public class ASCIIAndHEX { /** * 16进制转ASCII * * @param str * @return */ public static String toASCII(String str) { char[] chars = str.toCharArray(); StringBuffer hex = new StringBuffer(); for (int i = 0; i < chars.length; i++) { hex.append(Integer.toHexString((int) chars[i])); } return hex.toString(); } /** * ASCII转16进制 * * @param hex * ASCII码 * @return */ public static String toHex(String hex) { StringBuilder sb = new StringBuilder(); StringBuilder temp = new StringBuilder(); for (int i = 0; i < hex.length() - 1; i += 2) { String output = hex.substring(i, (i + 2)); int decimal = Integer.parseInt(output, 16); sb.append((char) decimal); temp.append(decimal); } return sb.toString(); } }
最近下载更多
wadadd LV7
2022年9月5日
756398953 LV12
2020年10月13日
古月剑独孤镖 LV3
2019年5月24日
904311498 LV1
2019年5月5日
vegetablebirds LV1
2019年3月7日
xie5461246464 LV6
2018年12月17日
谭鬼鬼 LV48
2018年8月15日