let int_of_charhex c = match c with
| '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9' -> int_of_string (string_of_char c);
| 'A' | 'a' -> 10;
| 'B' | 'b' -> 11;
| 'C' | 'c' -> 12;
| 'D' | 'd' -> 13;
| 'E' | 'e' -> 14;
| 'F' | 'f' -> 15