Android MD5 Encode toMD5(final String toEncrypt)

Here you can find the source of toMD5(final String toEncrypt)

Description

to MD

Declaration

public static final String toMD5(final String toEncrypt) 

Method Source Code

//package com.java2s;
import java.security.MessageDigest;

public class Main {
    public static final String toMD5(final String toEncrypt) {
        try {//from ww w  . ja  v a2s.  c o  m
            final MessageDigest digest = MessageDigest.getInstance("md5");
            digest.update(toEncrypt.getBytes());
            final byte[] bytes = digest.digest();
            final StringBuilder sb = new StringBuilder();
            for (int i = 0; i < bytes.length; i++) {
                sb.append(String.format("%02X", bytes[i]));
            }
            return sb.toString().toLowerCase();
        } catch (Exception exc) {
            return null; // Impossibru!
        }
    }
}

Related

  1. md5(String text)
  2. encryptByUsingMd5(String passwd)
  3. md5(String input)
  4. isValidMD5String(String md5String)
  5. stringToMD5(String key)