Java MD5 Sum md5sum(String url)

Here you can find the source of md5sum(String url)

Description

mdsum

License

Open Source License

Declaration

public static String md5sum(String url) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.io.UnsupportedEncodingException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

public class Main {
    public static String md5sum(String url) {
        if (url == null)
            return "";
        StringBuilder sb = new StringBuilder();
        try {/*from w  ww  .jav  a  2  s. c  o  m*/
            for (byte b : MessageDigest.getInstance("MD5").digest(url.getBytes("UTF-8")))
                sb.append(Integer.toHexString(0x100 | (b & 0xff)).substring(1));
        } catch (NoSuchAlgorithmException e) {
            throw new RuntimeException(e);
        } catch (UnsupportedEncodingException e) {
            throw new RuntimeException(e);
        }
        return sb.toString();
    }
}

Related

  1. md5sum(String inString)
  2. md5sum(String message)
  3. md5Sum(String msg)
  4. md5sum(String str)
  5. md5sum(String string)
  6. md5Summary(String str)