public static char[] encode(byte[] data) {

        int l = data.length;

        char[] out = new char[l << 1];

        // two characters form the hex value.
        for (int i = 0, j = 0; i < l; i++) {
            out[j++] = DIGITS[(0xF0 & data[i]) >>> 4];
            out[j++] = DIGITS[0x0F & data[i]];
        }

        return out;
    }
Converts an array of bytes into an array of characters representing the hexadecimal values of each byte in order.
The returned array will be double the length of the passed array, as it takes two characters to represent any
given byte.

@param data byte[] to convert to Hex characters
@return A char[] containing hexadecimal characters
src/main/java/org/apache/shiro/lang/codec/Hex.java