Java tutorial
//package com.java2s; //License from project: Open Source License import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; public class Main { private static final String SHA_1_ALGORITHM = "SHA-1"; /** * @param byteArray * @return byte[] * @throws NoSuchAlgorithmException */ public static byte[] getEncryptedMessageDigest(final byte[] byteArray) throws NoSuchAlgorithmException { return getEncryptedMessageDigest(byteArray, SHA_1_ALGORITHM); } /** * @param byteArray * @param algorithm * @return byte[] * @throws NoSuchAlgorithmException */ public static byte[] getEncryptedMessageDigest(final byte[] byteArray, final String algorithm) throws NoSuchAlgorithmException { return MessageDigest.getInstance(algorithm).digest(byteArray); } }