Java MD5 String MD5(String pData)

Here you can find the source of MD5(String pData)

Description

MD

License

Open Source License

Declaration

public static String MD5(String pData) 

Method Source Code

//package com.java2s;

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

public class Main {
    public static String MD5(String pData) {
        MessageDigest md = null;//from  w  w w .j ava2 s .c  o m
        try {
            md = MessageDigest.getInstance("MD5");
            md.update(pData.getBytes());
        } catch (NoSuchAlgorithmException e) {
            System.err.println("No such Algorithm!");
            return null;
        }

        byte[] digest = md.digest();
        StringBuffer lStr = new StringBuffer();
        for (int i = 0; i < digest.length; i++) {
            String s = Integer.toHexString(digest[i] & 0xFF);
            if (s.length() == 1)
                lStr.append("0");
            lStr.append(s);
        }
        return lStr.toString();
    }
}

Related

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