Java MD5 String Md5(String plainText)

Here you can find the source of Md5(String plainText)

Description

Md

License

Open Source License

Declaration

public static String Md5(String plainText) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

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

public class Main {
    public static String Md5(String plainText) {

        StringBuffer buf = new StringBuffer("");
        MessageDigest md;/* w  w w. j  a  va 2s.  c o m*/
        try {
            md = MessageDigest.getInstance("MD5");
            md.update(plainText.getBytes());
            byte b[] = md.digest();
            int i;
            for (int offset = 0; offset < b.length; offset++) {
                i = b[offset];
                if (i < 0)
                    i += 256;
                if (i < 16)
                    buf.append("0");
                buf.append(Integer.toHexString(i));
            }
        } catch (NoSuchAlgorithmException e) {
            e.printStackTrace();
        }
        return buf.toString().toUpperCase();
    }
}

Related

  1. md5(String password)
  2. md5(String password)
  3. md5(String path_of_file_)
  4. MD5(String pData)
  5. md5(String plain)
  6. md5(String plainText)
  7. Md5(String plainText)
  8. md5(String plainText)
  9. md5(String plainText)