Java SHA1 sha1Hash()

Here you can find the source of sha1Hash()

Description

sha Hash

License

Open Source License

Declaration

static public MessageDigest sha1Hash() throws NoSuchAlgorithmException 

Method Source Code

//package com.java2s;
/*/* w  ww .  ja  v  a2  s. c  o m*/
 * Copyright 2014-2017.
 * Distributed under the terms of the GPLv3 License.
 *
 * Authors:
 *      Clemens Zeidler <czei002@aucklanduni.ac.nz>
 */

import java.security.*;

public class Main {
    static public MessageDigest sha1Hash() throws NoSuchAlgorithmException {
        return MessageDigest.getInstance("SHA-1");
    }

    static public byte[] sha1Hash(byte data[]) {
        try {
            return hash(data, sha1Hash());
        } catch (Exception e) {
            System.out.println(e.getMessage());
            return null;
        }
    }

    static public byte[] hash(byte[] data, MessageDigest messageDigest) {
        messageDigest.reset();
        messageDigest.update(data);
        return messageDigest.digest();
    }
}

Related

  1. sha1Digest(final InputStream data)
  2. sha1Digest(String src)
  3. sha1DigestAsHex(String data)
  4. sha1Encode(byte[] content)
  5. SHA1Encode(String sourceString)
  6. sha1hash(byte[] blob)
  7. sha1Hash(byte[] data)
  8. sha1hash(Collection nquads)
  9. sha1hash(File f)