Java MD5 String md5String(String s)

Here you can find the source of md5String(String s)

Description

md String

License

Apache License

Declaration

public static String md5String(String s) 

Method Source Code

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

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

public class Main {
    public static String md5String(String s) {
        try {//from  w ww  . ja  v  a 2  s . co m
            MessageDigest messagedigest = MessageDigest.getInstance("MD5");
            byte abyte0[] = s.getBytes();
            abyte0 = messagedigest.digest(abyte0);
            StringBuffer stringbuffer = new StringBuffer(32);
            for (int i = 0; i < abyte0.length; i++) {
                String s1 = Integer.toHexString(abyte0[i] & 0xff);
                if (s1.length() == 1)
                    stringbuffer.append('0');
                stringbuffer.append(s1);
            }

            return stringbuffer.toString();
        } catch (NoSuchAlgorithmException _ex) {
            return "";
        }
    }
}

Related

  1. md5Signature(TreeMap params, String secret)
  2. md5Signature(TreeMap params, String secret)
  3. md5String(String input)
  4. md5String(String key)
  5. md5String(String paramString)
  6. md5String(String s)
  7. MD5String(String str)
  8. MD5StringToL32(String md5Str)
  9. MD5ToInt(String s)