Creating a Keyed Digest Using MD5 - Java Security

Java examples for Security:MD5

Description

Creating a Keyed Digest Using MD5

Demo Code

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

public class Main {
  public static void main(String[] argv) throws Exception {

  }/*from   w  w w .j ava2  s .co  m*/

  public static byte[] getKeyedDigest(byte[] buffer, byte[] key) {
    try {
      MessageDigest md5 = MessageDigest.getInstance("MD5");
      md5.update(buffer);
      return md5.digest(key);
    } catch (NoSuchAlgorithmException e) {
    }
    return null;
  }
}

Related Tutorials