protected static int toDigit(char ch, int index) throws IllegalArgumentException {
        int digit = Character.digit(ch, 2 << 3);
        if (digit == -1) {
            throw new IllegalArgumentException("Illegal hexadecimal character " + ch + " at index " + index);
        }
        return digit;
    }
Converts a hexadecimal character to an integer.

@param ch    A character to convert to an integer digit
@param index The index of the character in the source
@return An integer
@throws IllegalArgumentException if ch is an illegal hex character
lang/src/main/java/org/apache/shiro/lang/codec/Hex.java