Here you can find the source of toHexString(byte[] digest)
public static String toHexString(byte[] digest)
//package com.java2s; /**/*from w ww . j a va 2s . c o m*/ * Copyright (c) 2013 Puppet Labs, Inc. and other contributors, as listed below. * 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 * * Contributors: * Puppet Labs */ public class Main { private static final char[] hexChars = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' }; public static String toHexString(byte[] digest) { StringBuilder bld = new StringBuilder(); appendHex(bld, digest); return bld.toString(); } public static void appendHex(StringBuilder bld, byte b) { bld.append(hexChars[(b & 0xf0) >> 4]); bld.append(hexChars[b & 0x0f]); } public static void appendHex(StringBuilder bld, byte[] digest) { for (int idx = 0; idx < digest.length; ++idx) appendHex(bld, digest[idx]); } }