MD5 Encrypt byte array - Android java.security

Android examples for java.security:MD5

Description

MD5 Encrypt byte array

Demo Code

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

public class Main {

  public static byte[] md5Encrypt(byte[] byteArray) {
    byte[] retBytes = null;
    try {// w  w w  .jav a2s  . com
      MessageDigest md = MessageDigest.getInstance("MD5");
      md.update(byteArray);
      retBytes = md.digest();
    } catch (NoSuchAlgorithmException e) {
      e.printStackTrace();
    } catch (Exception e) {
      e.printStackTrace();
    }
    return retBytes;
  }

}

Related Tutorials