Java SHA1 sha1hash(byte[] blob)

Here you can find the source of sha1hash(byte[] blob)

Description

Perform a SHA-1 hash of a given byte array

License

Open Source License

Parameter

Parameter Description
blob Byte array to hash

Exception

Parameter Description
NoSuchAlgorithmException an exception

Return

SHA-1 hash of the specified byte array. Should always be 20 bytes in length

Declaration

public static byte[] sha1hash(byte[] blob)
        throws NoSuchAlgorithmException 

Method Source Code

//package com.java2s;

import java.security.*;

public class Main {
    /**/*from   www. ja  v a 2  s  .  c o  m*/
     * Perform a SHA-1 hash of a given byte array
     * @param blob Byte array to hash
     * @return SHA-1 hash of the specified byte array. Should always be 20 bytes in length
     * @throws NoSuchAlgorithmException
     */
    public static byte[] sha1hash(byte[] blob)
            throws NoSuchAlgorithmException {
        byte[] toReturn = null;
        MessageDigest md = MessageDigest.getInstance("SHA1");
        md.update(blob);
        toReturn = md.digest();
        return toReturn;
    }
}

Related

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