android字符串转换成16进制,参考如下内容:/** * 字符串转换成十六进制字符串 * @param String str 待转换的ASCII字符串 * @return String 每个Byte之间空格分隔,如: [61 6C 6B] */ public static String str2HexStr(String str) { char[] chars = "0123456789ABCDEF".toCharArray(); StringBuilder sb = new StringBuilder(""); byte[] bs = str.getBytes(); int bit; for (int i = 0; i < bs.length; i++) { bit = (bs[i] & 0x0f0) >> 4; sb.append(chars[bit]); bit = bs[i] & 0x0f; sb.append(chars[bit]); sb.append(' '); } return sb.toString().trim(); }
String转换成16进制的方法:public static String str2HexStr(String str){ char[] chars = "0123456789ABCDEF".toCharArray(); StringBuilder sb = new StringBuilder(""); byte[] bs = str.getBytes(); int bit; for (int i = 0; i < bs.length; i++) { bit = (bs[i] & 0x0f0) >> 4; sb.append(chars[bit]); bit = bs[i] & 0x0f; sb.append(chars[bit]); sb.append(' '); } return sb.toString().trim(); } 至于密钥加密得看你用什么加密方式进行加密了
String转换成16进制的方法:public static String str2HexStr(String str){ char[] chars = "0123456789ABCDEF".toCharArray(); StringBuilder sb = new StringBuilder(""); byte[] bs = str.getBytes(); int bit; for (int i = 0; i < bs.length; i++) { bit = (bs[i] & 0x0f0) >> 4; sb.append(chars[bit]); bit = bs[i] & 0x0f; sb.append(chars[bit]); sb.append(' '); } return sb.toString().trim(); } 至于密钥加密得看你用什么加密方式进行加密了
:String strInput ="湖北武汉"; StringBuffer output = new StringBuffer(); System.out.println("\""+strInput+ "\" 的utf8编码:")