sel-0.0.1.0: Cryptography for the casual user
Copyright(C) Hécate Moonlight 2023
LicenseBSD-3-Clause
MaintainerThe Haskell Cryptography Group
PortabilityGHC only
Safe HaskellSafe-Inferred
LanguageHaskell2010

Sel.Hashing.Short

Description

 
Synopsis

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

data ShortHash Source #

A 128-bit hash of a short input, of size cryptoShortHashSipHashX24Bytes

Since: 0.0.1.0

Instances

Instances details
Show ShortHash Source #

Since: 0.0.1.0

Instance details

Defined in Sel.Hashing.Short

Eq ShortHash Source #

Since: 0.0.1.0

Instance details

Defined in Sel.Hashing.Short

Ord ShortHash Source #

Since: 0.0.1.0

Instance details

Defined in Sel.Hashing.Short

Display ShortHash Source #

Since: 0.0.1.0

Instance details

Defined in Sel.Hashing.Short

Short-input Hashing

hashByteString Source #

Arguments

:: ShortHashKey

Random key produced by newKey

-> 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

hashText Source #

Arguments

:: ShortHashKey

Random key produced by newKey

-> 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 #

Convert a ShortHash to a strict hexadecimal-encoded Text.

Since: 0.0.1.0

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

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

shortHashKeyToHexText :: ShortHashKey -> Text Source #

Convert a ShortHash to a strict hexadecimal-encoded Text.

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

Constructors

ShortHashingException 

Instances

Instances details
Exception ShortHashingException Source #

Since: 0.0.1.0

Instance details

Defined in Sel.Hashing.Short

Show ShortHashingException Source #

Since: 0.0.1.0

Instance details

Defined in Sel.Hashing.Short

Eq ShortHashingException Source #

Since: 0.0.1.0

Instance details

Defined in Sel.Hashing.Short

Ord ShortHashingException Source #

Since: 0.0.1.0

Instance details

Defined in Sel.Hashing.Short

Display ShortHashingException Source #

Since: 0.0.1.0

Instance details

Defined in Sel.Hashing.Short