Java Digest digest(String alg, byte[] plainByte)

Here you can find the source of digest(String alg, byte[] plainByte)

Description

digest

License

Open Source License

Declaration

public static byte[] digest(String alg, byte[] plainByte) throws NoSuchAlgorithmException 

Method Source Code


//package com.java2s;

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

public class Main {

    public static byte[] digest(String alg, byte[] plainByte) throws NoSuchAlgorithmException {
        MessageDigest md = MessageDigest.getInstance(alg);
        md.update(plainByte);/*from   w ww .  ja v  a  2 s .  c  o  m*/
        return md.digest();
    }

    public static byte[] digest(String alg, byte[] plainByte, byte[] key) throws NoSuchAlgorithmException {
        MessageDigest md = MessageDigest.getInstance(alg);
        md.update(plainByte);
        return md.digest(key);
    }
}

Related

  1. digest(InputStream input, String algorithm)
  2. digest(InputStream is, String digestAlgorithm)
  3. digest(MessageDigest digest, InputStream data)
  4. digest(MessageDigest method, File f)
  5. digest(Serializable object)
  6. digest(String algorithm, byte[] bytes)
  7. digest(String algorithm, byte[] data)
  8. digest(String algorithm, String data)
  9. digest(String aValue)