1 /** 2 * SHA_1计算消息摘要 3 * @param bytes 待计算数据 4 * @return 5 */ 6 public static String SHA_1(byte[] bytes) { 7 String encodeBase64String = null; 8 try { 9 MessageDigest md = MessageDigest.getInstance("SHA1"); 10 md.update(bytes); 11 byte[] _bytes = md.digest(); 12 encodeBase64String = Base64.encodeBase64String(_bytes); 13 } catch (NoSuchAlgorithmException ex) { 14 ex.printStackTrace(); 15 } 16 return encodeBase64String; 17 }
时间: 2024-10-03 23:24:31