Here you can find the source of digest(final String algorithm, final byte[] bytes)
Parameter | Description |
---|---|
algorithm | The algorithm to use when generating the hash value. |
bytes | The byte array for which to compute the hash value. |
public static byte[] digest(final String algorithm, final byte[] bytes)
//package com.java2s; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; public class Main { /**//from w ww. ja v a2s. c o m * Gets the given byte array's hash value according to the specified * algorithm. * * @param algorithm The algorithm to use when generating the hash value. * @param bytes The byte array for which to compute the hash value. * @return The computed hash value, or null if the digest algorithm is not * available. * @see MessageDigest */ public static byte[] digest(final String algorithm, final byte[] bytes) { try { final MessageDigest digest = MessageDigest.getInstance(algorithm); digest.update(bytes); return digest.digest(); } catch (final NoSuchAlgorithmException exc) { return null; } } }