Here you can find the source of generateDigest(byte[] inputBytes)
Parameter | Description |
---|---|
inputBytes | a parameter |
Parameter | Description |
---|---|
Exception | an exception |
public static synchronized byte[] generateDigest(byte[] inputBytes) throws Exception
//package com.java2s; import java.security.MessageDigest; public class Main { private static MessageDigest digest = null; /**//w ww . j a v a 2s.co m * Generate a (SHA1) digest of the input bytes. The MessageDigest * instance that backs this method is cached for efficiency. * * @param inputBytes * @return * @throws Exception */ public static synchronized byte[] generateDigest(byte[] inputBytes) throws Exception { try { if (digest == null) digest = MessageDigest.getInstance("SHA-1"); return digest.digest(inputBytes); } catch (Exception e) { throw new Exception("[SecUtil] Error in generating digest"); } } }