Here you can find the source of SHA1(byte[] data)
Parameter | Description |
---|---|
data | original data |
public static String SHA1(byte[] data)
//package com.java2s; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; public class Main { /**/*from www . j av a 2 s . c om*/ * SHA-1 encrypt method * @param data original data * @return encrypt data */ public static String SHA1(byte[] data) { MessageDigest md; try { md = MessageDigest.getInstance("SHA-1"); } catch (NoSuchAlgorithmException e) { return null; } md.update(data); byte[] encdata = md.digest(); StringBuffer sb = new StringBuffer(); for (int i = 0; i < encdata.length; i++) { sb.append(Integer.toHexString(encdata[i] & 0xff)); } return sb.toString(); } }