Java MD5 String md5(String encryptStr)

Here you can find the source of md5(String encryptStr)

Description

md

License

Apache License

Declaration

public static String md5(String encryptStr) throws Exception 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.security.MessageDigest;

public class Main {
    public static String md5(String encryptStr) throws Exception {
        MessageDigest md = MessageDigest.getInstance("MD5");
        md.update(encryptStr.getBytes("UTF-8"));
        byte[] digest = md.digest();
        StringBuffer md5 = new StringBuffer();
        for (int i = 0; i < digest.length; i++) {
            md5.append(Character.forDigit((digest[i] & 0xF0) >> 4, 16));
            md5.append(Character.forDigit((digest[i] & 0xF), 16));
        }/*w w  w  .  ja  va 2  s.  c  o m*/

        encryptStr = md5.toString();
        return encryptStr;
    }
}

Related

  1. md5(String data)
  2. md5(String data)
  3. md5(String data)
  4. md5(String data)
  5. md5(String data)
  6. md5(String input)
  7. md5(String input)
  8. md5(String input)
  9. md5(String input)