Java SHA1 digestSHA1(byte[] data)

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

Description

digest SHA

License

Apache License

Declaration

public static byte[] digestSHA1(byte[] data) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

public class Main {
    public static final String ALGORITHM_SHA1 = "SHA1";

    public static byte[] digestSHA1(byte[] data) {
        return digest(data, ALGORITHM_SHA1);
    }/*w w  w.  java  2s.com*/

    public static byte[] digest(byte[] data, String algorithm) {
        if (data == null || data.length <= 0) {
            return null;
        }
        try {
            MessageDigest md = MessageDigest.getInstance(algorithm);
            md.update(data);
            return md.digest();
        } catch (NoSuchAlgorithmException e) {
            e.printStackTrace();
            return null;
        }
    }
}

Related

  1. computeSha1(byte[] data)
  2. computeSHA1(ByteBuffer convertme, int offset, int len)
  3. computeSha1(ReadableByteChannel channel)
  4. computeSha1AsHexString(String strToHash)
  5. computeSHA1Hash(byte[] data)
  6. digestSHA1(String data)
  7. digestSHA1(String login, String pass)
  8. digestSHA1(String text)
  9. digestSha1Hex(String source)