private static void encodeHex(final byte[] data, final int dataOffset, final int dataLen, final char[] toDigits,
                                  final char[] out, final int outOffset) {
        // two characters form the hex value.
        for (int i = dataOffset, j = outOffset; i < dataOffset + dataLen; i++) {
            out[j++] = toDigits[(0xF0 & data[i]) >>> 4];
            out[j++] = toDigits[0x0F & data[i]];
        }
    }
Converts an array of bytes into an array of characters representing the hexadecimal values of each byte in order.

@param data       a byte[] to convert to hex characters
@param dataOffset the position in {@code data} to start encoding from
@param dataLen    the number of bytes from {@code dataOffset} to encode
@param toDigits   the output alphabet (must contain at least 16 chars)
@param out        a char[] which will hold the resultant appropriate characters from the alphabet.
@param outOffset  the position within {@code out} at which to start writing the encoded characters.
httpclient5/src/main/java/org/apache/hc/client5/http/utils/Hex.java