Java MD5 String md5(String source)

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

Description

md

License

Apache License

Declaration

public static String md5(String source) 

Method Source Code

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

import java.security.MessageDigest;

public class Main {
    public static String md5(String source) {
        StringBuffer sb = new StringBuffer(32);
        try {//from   www.  j  a  va2s .  c o  m
            MessageDigest md = MessageDigest.getInstance("MD5");
            byte[] array = md.digest(source.getBytes("utf-8"));
            for (int i = 0; i < array.length; i++) {
                sb.append(Integer.toHexString((array[i] & 0xFF) | 0x100).toUpperCase().substring(1, 3));
            }
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }

        return sb.toString();
    }
}

Related

  1. md5(String sInput)
  2. md5(String source)
  3. md5(String source)
  4. md5(String source)
  5. md5(String source)
  6. md5(String source, int bit)
  7. MD5(String sourceStr)
  8. MD5(String src)
  9. md5(String src)