Here you can find the source of newMD5HashUri(String value)
public final static String newMD5HashUri(String value)
//package com.java2s; /**/*from w ww . j a v a 2 s. c o m*/ * Copyright (C) 2010 University of Washington * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except * in compliance with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express * or implied. See the License for the specific language governing permissions and limitations under * the License. */ import java.io.UnsupportedEncodingException; import java.math.BigInteger; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; public class Main { public final static String newMD5HashUri(String value) { try { MessageDigest md = MessageDigest.getInstance("MD5"); byte[] asBytes; try { asBytes = value.getBytes("UTF-8"); } catch (UnsupportedEncodingException e) { e.printStackTrace(); throw new IllegalStateException("unexpected", e); } md.update(asBytes); byte[] messageDigest = md.digest(); BigInteger number = new BigInteger(1, messageDigest); String md5 = number.toString(16); while (md5.length() < 32) md5 = "0" + md5; return "md5:" + md5; } catch (NoSuchAlgorithmException e) { throw new IllegalStateException("Unexpected problem computing md5 hash", e); } } public final static String newMD5HashUri(byte[] asBytes) { try { MessageDigest md = MessageDigest.getInstance("MD5"); md.update(asBytes); byte[] messageDigest = md.digest(); BigInteger number = new BigInteger(1, messageDigest); String md5 = number.toString(16); while (md5.length() < 32) md5 = "0" + md5; return "md5:" + md5; } catch (NoSuchAlgorithmException e) { throw new IllegalStateException("Unexpected problem computing md5 hash", e); } } }