Android MD5 Encode stringGetMD5String(String s)

Here you can find the source of stringGetMD5String(String s)

Description

string Get MD String

License

Open Source License

Declaration

public static String stringGetMD5String(String s) 

Method Source Code

//package com.java2s;

import java.security.MessageDigest;

public class Main {
    public static String stringGetMD5String(String s) {
        byte[] data;
        MessageDigest md5;//w  w  w .j a  v a 2  s  .  c om

        try {
            data = s.getBytes("UTF-8");
            md5 = MessageDigest.getInstance("MD5");
        } catch (Exception e) {
            return null;
        }

        byte[] hash = md5.digest(data);
        StringBuilder hashStr = new StringBuilder();

        for (byte byteValue : hash) {
            hashStr.append(String.format("%02x", byteValue));
        }

        return hashStr.toString();
    }
}

Related

  1. getMd5(byte... values)
  2. checkDicMD5(String dicFile, final byte[] expected)
  3. MD5(String md5)
  4. getMD5Str(String str)
  5. MD5(String text)
  6. byteMd5(String plainText, Boolean is16)
  7. getMD5(byte[] source)
  8. md5(String string)
  9. createHMACWithMD5(String source, String key)