Java MD5 String MD5(String string)

Here you can find the source of MD5(String string)

Description

MD

License

Apache License

Declaration

public static String MD5(String string) 

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 MD5(String string) {
        try {//from   www.  ja  v a2 s. c o  m
            MessageDigest md = MessageDigest.getInstance("MD5");
            md.update(string.getBytes());
            byte[] digest = md.digest();
            StringBuilder sb = new StringBuilder();
            for (byte b : digest) {
                sb.append(String.format("%02x", b & 0xff));
            }
            return sb.toString();
        } catch (NoSuchAlgorithmException e) {
            e.printStackTrace();
        }
        return null;
    }
}

Related

  1. MD5(String str)
  2. MD5(String str)
  3. md5(String str)
  4. md5(String str)
  5. MD5(String str)
  6. md5(String string)
  7. md5(String string)
  8. md5(String string)
  9. md5(String string)