Java MD5 String md5(String inStr)

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

Description

generate 32-bit md5

License

Open Source License

Parameter

Parameter Description
inStr a parameter

Declaration

public static byte[] md5(String inStr) 

Method Source Code


//package com.java2s;
import java.security.MessageDigest;

public class Main {
    /**/*from  www.  j  a  v a2  s .c om*/
     * generate 32-bit md5
     * @param inStr
     * @return
     * @author <a href="mailto:iffiff1@gmail.com">Tyler Chen</a> 
     * @since 2015-2-6
     */
    public static byte[] md5(String inStr) {
        MessageDigest md5 = null;
        try {
            md5 = MessageDigest.getInstance("MD5");
        } catch (Exception e) {
            System.out.println(e.toString());
            e.printStackTrace();
            return new byte[0];
        }
        char[] charArray = inStr.toCharArray();
        byte[] byteArray = new byte[charArray.length];

        for (int i = 0; i < charArray.length; i++) {
            byteArray[i] = (byte) charArray[i];
        }
        return md5.digest(byteArray);
    }
}

Related

  1. md5(String input)
  2. md5(String input)
  3. MD5(String input)
  4. MD5(String inputString)
  5. md5(String inputText)
  6. md5(String key)
  7. md5(String md5)
  8. MD5(String md5)
  9. md5(String message)