Android MD5 Encode md5(final String s)

Here you can find the source of md5(final String s)

Description

md

Declaration

public static final String md5(final String s) 

Method Source Code

//package com.java2s;

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

public class Main {
    public static final String md5(final String s) {
        try {//from   w  w w .  ja  v  a 2  s  .  c  om
            // Create MD5 Hash
            MessageDigest digest = java.security.MessageDigest
                    .getInstance("MD5");
            digest.update(s.getBytes());
            byte messageDigest[] = digest.digest();

            // Create Hex String
            StringBuffer hexString = new StringBuffer();
            for (int i = 0; i < messageDigest.length; i++) {
                String h = Integer.toHexString(0xFF & messageDigest[i]);
                while (h.length() < 2)
                    h = "0" + h;
                hexString.append(h);
            }
            return hexString.toString();

        } catch (NoSuchAlgorithmException e) {
            e.printStackTrace();
        }
        return "";
    }
}

Related

  1. MD5Encode(String origin)
  2. getMD5Code(String value)
  3. getMD5(String s)
  4. MD5(String s)
  5. md5(final String s)
  6. hexMD5(String input)
  7. getMD5(String str)
  8. getMD5Digest(String str)
  9. computeMd5Hash(byte[] in)