Copyright | (c) 2024 Auth Global |
---|---|
License | Apache2 |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
binary string types supporting constant-time base16 encoding and decoding, as well as constant time lexicographic comparisons. Note that the time required does depend linearly on length, but is otherwise data-independent.
Synopsis
- data HashString
- fromShort :: ShortByteString -> HashString
- fromShortBase16 :: ShortByteString -> Maybe HashString
- toShort :: HashString -> ShortByteString
- toShortBase16 :: HashString -> ShortByteString
- fromByteString :: ByteString -> HashString
- fromBase16 :: ByteString -> Maybe HashString
- toByteString :: HashString -> ByteString
- toBase16 :: HashString -> ByteString
- toBase16Builder :: HashString -> Builder
- xorLeft :: HashString -> HashString -> HashString
- xorMin :: HashString -> HashString -> HashString
- xorMax :: HashString -> HashString -> HashString
- takeBytes :: Foldable f => Int -> f HashString -> [HashString]
Documentation
data HashString Source #
Type intended to represent short-ish cryptographic values, say up to 128 bytes or so. Supports constant-time comparisons (i.e. run time depends on length of the inputs but is otherwise independent of content), as well as constant-time base16 and base64 conversions.
Instances
toShort :: HashString -> ShortByteString Source #
fromBase16 :: ByteString -> Maybe HashString Source #
toByteString :: HashString -> ByteString Source #
toBase16 :: HashString -> ByteString Source #
toBase16Builder :: HashString -> Builder Source #
xorLeft :: HashString -> HashString -> HashString Source #
Xor two hashstrings. The length of the result is always the same as the length of the left argument; bytes are either removed from or added to the end of the right argument as needed to match length.
xorMin :: HashString -> HashString -> HashString Source #
Xor two hashstrings. The length of the result is always the same as the length of the shorter argument, removing bytes from the end of the longer string as needed to match length.
xorMax :: HashString -> HashString -> HashString Source #
Xor two hashstrings. The length of the result is always the same as the length of the longer argument, adding null bytes onto the end of the shorter string as needed to match length.
takeBytes :: Foldable f => Int -> f HashString -> [HashString] Source #