Java SHA1 SHA1(byte[] data)

Here you can find the source of SHA1(byte[] data)

Description

SHA-1 encrypt method

License

Open Source License

Parameter

Parameter Description
data original data

Return

encrypt data

Declaration

public static String SHA1(byte[] data) 

Method Source Code


//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();
    }
}

Related

  1. SHA1(byte[] bytes)
  2. sha1(byte[] bytes)
  3. sha1(byte[] bytes)
  4. sha1(byte[] bytes)
  5. SHA1(byte[] convertme)
  6. sha1(byte[] data)
  7. sha1(byte[] data)
  8. sha1(byte[] data)
  9. sha1(byte[] data)