Here you can find the source of toHexString(byte bytes[])
Parameter | Description |
---|---|
bytes | the bytes to be converted |
protected static String toHexString(byte bytes[])
//package com.java2s; //License from project: Open Source License public class Main { protected static final char HEXCODE[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' }; /**/*w ww.j ava2 s. c o m*/ * Convert a collection of bytes from an MD5 hash to a string. * @param bytes the bytes to be converted * @return the resulting string */ protected static String toHexString(byte bytes[]) { char chars[] = new char[bytes.length * 2]; for (int i = 0; i < bytes.length; ++i) { chars[2 * i] = HEXCODE[(bytes[i] & 0xF0) >>> 4]; chars[2 * i + 1] = HEXCODE[bytes[i] & 0x0F]; } return new String(chars); } }