All Downloads are FREE. Search and download functionalities are using the official Maven repository.

bt.service.CryptoUtil Maven / Gradle / Ivy

There is a newer version: 1.10
Show newest version
package bt.service;

import bt.BtException;

import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

/**
 * This utility class provides cryptographic functions.
 *
 * @since 1.0
 */
public class CryptoUtil {

    /**
     * Calculate SHA-1 digest of a byte array.
     *
     * @since 1.0
     */
    public static byte[] getSha1Digest(byte[] bytes) {
        MessageDigest cryptor;
        try {
            cryptor = MessageDigest.getInstance("SHA-1");
        } catch (NoSuchAlgorithmException e) {
            throw new BtException("Unexpected error", e);
        }
        return cryptor.digest(bytes);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy