Java Digest digest(byte[] data, String algorithm)

Here you can find the source of digest(byte[] data, String algorithm)

Description

digest

License

Apache License

Declaration

public static byte[] digest(byte[] data, String algorithm) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

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

public class Main {
    public static byte[] digest(byte[] data, String algorithm) {
        if (data == null || data.length <= 0) {
            return null;
        }/*from w  w w  .j a  v a  2 s  . com*/
        try {
            MessageDigest md = MessageDigest.getInstance(algorithm);
            md.update(data);
            return md.digest();
        } catch (NoSuchAlgorithmException e) {
            e.printStackTrace();
            return null;
        }
    }
}

Related

  1. digest(byte[] bytes, String algorithm)
  2. digest(byte[] bytes, String algorithmName)
  3. digest(byte[] bytes, String txt)
  4. digest(byte[] data)
  5. digest(byte[] data, String algorithm)
  6. digest(byte[] input)
  7. digest(byte[] input, final String algorithm)
  8. digest(byte[] input, String algorithm, byte[] salt, int iterations)
  9. digest(byte[] message, String hash_alg)