Java Utililty Methods Digest

List of utility methods to do Digest

Description

The list of methods to do Digest are organized into topic(s).

Method

byte[]digest(byte[] input, String algorithm, byte[] salt, int iterations)
digest
try {
    MessageDigest digest = MessageDigest.getInstance(algorithm);
    if (salt != null) {
        digest.update(salt);
    byte[] result = digest.digest(input);
    for (int i = 1; i < iterations; i++) {
        digest.reset();
...
byte[]digest(byte[] message, String hash_alg)
Compute digest
MessageDigest digest;
try {
    digest = MessageDigest.getInstance(hash_alg); 
} catch (NoSuchAlgorithmException e) {
    e.printStackTrace();
    return null;
if (DEBUG)
...
byte[]digest(final @Nullable String[] tokens, @Nullable final Date[] dates)
digest
try {
    String mixName = "";
    if (tokens != null) {
        for (final String token : tokens) {
            mixName += (token != null ? token.trim() : "");
    if (dates != null) {
...
byte[]digest(final byte[] data)
Genera la huella digital de los datos con el algoritmo indicado por DEFAULT_MESSAGE_DIGEST_ALGORITHM .
if (md == null) {
    try {
        md = MessageDigest.getInstance(DEFAULT_MESSAGE_DIGEST_ALGORITHM);
    } catch (final NoSuchAlgorithmException e) {
        LOGGER.severe("Se ha utilizado internamente un algoritmo de huella digital no soportado: " + e); 
        throw new IllegalArgumentException("Algoritmo no soportado", e); 
return md.digest(data);
InputStreamdigest(final InputStream inputStream, final MessageDigest digester)
digest
return new DigestInputStream(removeOSSpecificChars(inputStream), digester);
byte[]digest(final java.security.MessageDigest messageDigest, final java.nio.ByteBuffer data)
digest
messageDigest.update(data);
return messageDigest.digest();
byte[]digest(final String algorithm, final byte[] bytes)
Gets the given byte array's hash value according to the specified algorithm.
try {
    final MessageDigest digest = MessageDigest.getInstance(algorithm);
    digest.update(bytes);
    return digest.digest();
} catch (final NoSuchAlgorithmException exc) {
    return null;
Stringdigest(final String password)
Digests password with MD5 and encodes it as a hex String.
final MessageDigest messageDigest = MessageDigest.getInstance("MD5");
messageDigest.reset();
messageDigest.update(password.trim().toLowerCase().getBytes());
return encodeToHex(messageDigest.digest());
Stringdigest(InputStream input, String algorithm)
digest
Stopwatch sw = Stopwatch.createStarted();
int bufferSize = 256 * 1024;
MessageDigest messageDigest = MessageDigest.getInstance(algorithm);
try (DigestInputStream digestInputStream = new DigestInputStream(input, messageDigest);) {
    byte[] buffer = new byte[bufferSize];
    while (digestInputStream.read(buffer) > 0) {
        ;
    messageDigest = digestInputStream.getMessageDigest();
    byte[] resultByteArray = messageDigest.digest();
    return byteArrayToHex(resultByteArray);
} finally {
    sw.stop();
byte[]digest(InputStream is, String digestAlgorithm)
digest
MessageDigest digestor = MessageDigest.getInstance(digestAlgorithm);
int bufSize = 1048576; 
byte[] buffer = new byte[bufSize];
int n = is.read(buffer, 0, bufSize);
while (n != -1) {
    digestor.update(buffer, 0, n);
    n = is.read(buffer, 0, bufSize);
is.close();
return digestor.digest();