Copyright | (C) Hécate Moonlight 2023 |
---|---|
License | BSD-3-Clause |
Maintainer | The Haskell Cryptography Group |
Portability | GHC only |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
Synopsis
- data ShortHash
- hashByteString :: ShortHashKey -> StrictByteString -> IO ShortHash
- hashText :: ShortHashKey -> Text -> IO ShortHash
- shortHashToBinary :: ShortHash -> StrictByteString
- shortHashToHexText :: ShortHash -> Text
- shortHashToHexByteString :: ShortHash -> StrictByteString
- data ShortHashKey
- newKey :: IO ShortHashKey
- shortHashKeyToBinary :: ShortHashKey -> StrictByteString
- shortHashKeyToHexText :: ShortHashKey -> Text
- shortHashKeyToHexByteString :: ShortHashKey -> StrictByteString
- binaryToShortHashKey :: StrictByteString -> Maybe ShortHashKey
- hexTextToShortHashKey :: Text -> Maybe ShortHashKey
- hexByteStringToShortHashKey :: StrictByteString -> Maybe ShortHashKey
- data ShortHashingException = ShortHashingException
Introduction
This module provides an API for performant short-input hashing, backed by the SipHash-2-4 algorithm.
Short-input hashing functions have a variety of use-cases, such as:
- Hash Tables
- Probabilistic data structures, such as Bloom filters
- Integrity checking in interactive protocols
A 128-bit hash of a short input, of size cryptoShortHashSipHashX24Bytes
Since: 0.0.1.0
Instances
Show ShortHash Source # | Since: 0.0.1.0 |
Eq ShortHash Source # | Since: 0.0.1.0 |
Ord ShortHash Source # | Since: 0.0.1.0 |
Defined in Sel.Hashing.Short | |
Display ShortHash Source # | Since: 0.0.1.0 |
Defined in Sel.Hashing.Short displayBuilder :: ShortHash -> Builder # displayList :: [ShortHash] -> Builder # displayPrec :: Int -> ShortHash -> Builder # |
Short-input Hashing
:: ShortHashKey | Random key produced by |
-> StrictByteString | Data to hash |
-> IO ShortHash |
Hash a StrictByteString
.
The same message hashed with the same key will always produce the same output.
The ShortHash
is of length cryptoShortHashSipHashX24Bytes
Since: 0.0.1.0
:: ShortHashKey | Random key produced by |
-> Text | UTF-8 encoded data to hash |
-> IO ShortHash |
Hash a strict Text
.
The same message hashed with the same key will always produce the same output.
The ShortHash
is of length cryptoShortHashSipHashX24Bytes
Since: 0.0.1.0
Conversion
shortHashToBinary :: ShortHash -> StrictByteString Source #
Convert a ShortHash
to a strict binary StrictByteString
.
Since: 0.0.1.0
shortHashToHexText :: ShortHash -> Text Source #
shortHashToHexByteString :: ShortHash -> StrictByteString Source #
Convert a ShortHash
to a hexadecimal-encoded StrictByteString
.
Since: 0.0.1.0
Short Hash Key
data ShortHashKey Source #
A random key used for hashing, of size cryptoShortHashSipHashX24KeyBytes
.
The same message hashed with the same key will always produce the same output.
Since: 0.0.1.0
Instances
Show ShortHashKey Source # | Since: 0.0.1.0 |
Defined in Sel.Hashing.Short showsPrec :: Int -> ShortHashKey -> ShowS # show :: ShortHashKey -> String # showList :: [ShortHashKey] -> ShowS # | |
Eq ShortHashKey Source # | Since: 0.0.1.0 |
Defined in Sel.Hashing.Short (==) :: ShortHashKey -> ShortHashKey -> Bool # (/=) :: ShortHashKey -> ShortHashKey -> Bool # | |
Ord ShortHashKey Source # | Since: 0.0.1.0 |
Defined in Sel.Hashing.Short compare :: ShortHashKey -> ShortHashKey -> Ordering # (<) :: ShortHashKey -> ShortHashKey -> Bool # (<=) :: ShortHashKey -> ShortHashKey -> Bool # (>) :: ShortHashKey -> ShortHashKey -> Bool # (>=) :: ShortHashKey -> ShortHashKey -> Bool # max :: ShortHashKey -> ShortHashKey -> ShortHashKey # min :: ShortHashKey -> ShortHashKey -> ShortHashKey # | |
Display ShortHashKey Source # | |
Defined in Sel.Hashing.Short displayBuilder :: ShortHashKey -> Builder # displayList :: [ShortHashKey] -> Builder # displayPrec :: Int -> ShortHashKey -> Builder # |
newKey :: IO ShortHashKey Source #
Generate a random ShortHashKey
of size cryptoShortHashSipHashX24KeyBytes
Since: 0.0.1.0
Conversion
shortHashKeyToBinary :: ShortHashKey -> StrictByteString Source #
Convert a ShortHash
to a strict binary StrictByteString
.
Since: 0.0.1.0
shortHashKeyToHexByteString :: ShortHashKey -> StrictByteString Source #
Convert a ShortHash
to a hexadecimal-encoded StrictByteString
.
Since: 0.0.1.0
binaryToShortHashKey :: StrictByteString -> Maybe ShortHashKey Source #
Convert a binary StrictByteString
to a ShortHashKey
.
The input key must be of length cryptoShortHashSipHashX24KeyBytes
Since: 0.0.1.0
hexTextToShortHashKey :: Text -> Maybe ShortHashKey Source #
Convert a strict hexadecimal-encoded Text
to a ShortHashKey
.
The input key, once decoded from base16, must be of length cryptoShortHashSipHashX24KeyBytes
Since: 0.0.1.0
hexByteStringToShortHashKey :: StrictByteString -> Maybe ShortHashKey Source #
Convert a hexadecimal-encoded StrictByteString
to a ShortHashKey
.
The input key, once decoded from base16, must be of length cryptoShortHashSipHashX24KeyBytes
Since: 0.0.1.0
Errors
data ShortHashingException Source #
Exception thrown upon error during hashing by
hashByteString
or hashText
.
Since: 0.0.1.0