Java MD5 md5ToHex(byte[] hash)

Here you can find the source of md5ToHex(byte[] hash)

Description

md To Hex

License

Open Source License

Declaration

public static String md5ToHex(byte[] hash) 

Method Source Code

//package com.java2s;
/*//from  w  ww  .ja va 2s . com
 * (C) Copyright 2006-2011 Nuxeo SA (http://nuxeo.com/) and contributors.
 *
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the GNU Lesser General Public License
 * (LGPL) version 2.1 which accompanies this distribution, and is available at
 * http://www.gnu.org/licenses/lgpl.html
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 * Contributors:
 *     bstefanescu
 */

public class Main {
    public static String md5ToHex(byte[] hash) {
        StringBuilder hexString = new StringBuilder();
        for (byte b : hash) {
            String hex = Integer.toHexString(0xFF & b);
            if (hex.length() == 1) {
                hexString.append('0');
            }
            hexString.append(hex);
        }
        return hexString.toString();
    }
}

Related

  1. md5HashByteToString(byte[] bytes)
  2. md5HashStringToByte(String hash)
  3. md5Hex(final String text)
  4. md5Init()
  5. md5Memcpy(byte[] output, byte[] input, int outpos, int inpos, int len)
  6. md5ToString(byte[] md5sum)
  7. md5Update(byte[] inbuf, int inputLen)
  8. newMd5()
  9. newMD5HashUri(String value)