Here you can find the source of tohex(final byte[] bytes)
public static String tohex(final byte[] bytes)
//package com.java2s; /******************************************************************************* * Copyright (c) 2017 JCrypTool Team and Contributors * * 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 { private static final int UNSIGNED_BYTE_MASK = 0xFF; public static String tohex(final byte[] bytes) { final StringBuilder sb = new StringBuilder(bytes.length * 2); for (int i = 0; i < bytes.length; i++) { sb.append(String.format("%02X", bytes[i] & UNSIGNED_BYTE_MASK)); }//from w w w. ja va2 s. c o m return sb.toString(); } public static String tohex(long[] longs) { StringBuilder sb = new StringBuilder(); for (int i = 0; i < longs.length; i++) { sb.append(String.format("0x%016X", longs[i])); if (i != longs.length - 1) { sb.append(", "); if (i % 4 == 3) { sb.append(String.format("%n")); } } } sb.append(String.format("%n")); return sb.toString(); } }