Here you can find the source of toHexString(byte[] digest)
public static String toHexString(byte[] digest)
//package com.java2s; /******************************************************************************* * Copyright (c) 2011 Sonatype, Inc./*from w ww . j a v a 2 s .c o m*/ * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html *******************************************************************************/ public class Main { public static String toHexString(byte[] digest) { String chars = "0123456789abcdef"; StringBuilder buffer = new StringBuilder(digest.length * 2); for (int i = 0; i < digest.length; i++) { int b = digest[i] & 0xFF; buffer.append(chars.charAt(b >> 4)); buffer.append(chars.charAt(b & 0xF)); } return buffer.toString(); } }