Here you can find the source of sha1hash(byte[] blob)
Parameter | Description |
---|---|
blob | Byte array to hash |
Parameter | Description |
---|---|
NoSuchAlgorithmException | an exception |
public static byte[] sha1hash(byte[] blob) throws NoSuchAlgorithmException
//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; } }