0 | module Oracle.Internal.Hex
15 | hexDigit : Bits8 -> Char
48 | hexByte : Bits8 -> String
51 | [ hexDigit (byte `shiftR` 4)
52 | , hexDigit (byte .&. 0x0F)
72 | hexEncode : List Bits8 -> String
81 | hexValue : Char -> Maybe Bits8
82 | hexValue '0' = Just 0
83 | hexValue '1' = Just 1
84 | hexValue '2' = Just 2
85 | hexValue '3' = Just 3
86 | hexValue '4' = Just 4
87 | hexValue '5' = Just 5
88 | hexValue '6' = Just 6
89 | hexValue '7' = Just 7
90 | hexValue '8' = Just 8
91 | hexValue '9' = Just 9
92 | hexValue 'A' = Just 10
93 | hexValue 'B' = Just 11
94 | hexValue 'C' = Just 12
95 | hexValue 'D' = Just 13
96 | hexValue 'E' = Just 14
97 | hexValue 'F' = Just 15
98 | hexValue 'a' = Just 10
99 | hexValue 'b' = Just 11
100 | hexValue 'c' = Just 12
101 | hexValue 'd' = Just 13
102 | hexValue 'e' = Just 14
103 | hexValue 'f' = Just 15
104 | hexValue _ = Nothing
109 | hexPair : Char -> Char -> Maybe Bits8
113 | pure $
(hi' `shiftL` 4) .|. lo'
121 | hexDecode : String -> Maybe (List Bits8)
125 | go : List Char -> Maybe (List Bits8)
127 | go (hi :: lo :: rest) = do
128 | byte <- hexPair hi lo
130 | pure (byte :: bytes)