Java MD5 Encode md5Encode(String strPlain)

Here you can find the source of md5Encode(String strPlain)

Description

md Encode

License

Open Source License

Declaration

public static String md5Encode(String strPlain) 

Method Source Code

//package com.java2s;

import java.security.MessageDigest;

public class Main {

    public static String md5Encode(String strPlain) {
        byte[] s = md5(strPlain);
        StringBuilder result = new StringBuilder();
        for (int i = 0; i < s.length; i++) {
            result.append(Integer.toHexString((0x000000ff & s[i]) | 0xffffff00).substring(6));
        }//w w  w .j  a  v  a  2  s .  c om
        return result.toString();
    }

    public static byte[] md5(String strPlain) {
        byte s[] = null;
        try {
            MessageDigest m = MessageDigest.getInstance("MD5");
            m.update(strPlain.getBytes("UTF8"));
            s = m.digest();
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
        return s;
    }
}

Related

  1. Md5Encode(String source)
  2. md5Encode(String source)
  3. MD5Encode(String sourceString)
  4. md5Encode(String src)
  5. MD5Encode(String str)
  6. MD5Encoder(String s, String charset)
  7. md5encoding(String data)
  8. md5Encoding(String s)
  9. MD5Encoding(String source)