标签:sig private for ati int update git stack 进制
话不多说上码
public static byte[] digest(String signStr) { MessageDigest md5Instance = null; try { md5Instance = MessageDigest.getInstance("MD5"); md5Instance.update(signStr.getBytes("utf-8")); } catch (NoSuchAlgorithmException e) { e.printStackTrace(); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } return md5Instance.digest(); }
得到byte数据,转16进制后的字符串
//加密后转 private static String byte2Hex(byte[] bytes) { char hexDigits[] = { ‘0‘, ‘1‘, ‘2‘, ‘3‘, ‘4‘, ‘5‘, ‘6‘, ‘7‘, ‘8‘, ‘9‘, ‘A‘, ‘B‘, ‘C‘, ‘D‘, ‘E‘, ‘F‘ }; int j = bytes.length; char str[] = new char[j * 2]; int k = 0; for (byte byte0 : bytes) { str[k++] = hexDigits[byte0 >>> 4 & 0xf]; str[k++] = hexDigits[byte0 & 0xf]; } return new String(str); }
最终得到你想要的
标签:sig private for ati int update git stack 进制
原文地址:https://www.cnblogs.com/dzcici/p/10917201.html