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

Sel.Hashing.SHA512

Description

 
Synopsis

Usage

The SHA-2 family of hashing functions is only provided for interoperability with other applications.

If you are looking for a generic hash function, do use Hashing.

If you are looking to hash passwords or deriving keys from passwords, do use Password, as the functions of the SHA-2 family are not suitable for this task.

Only import this module qualified like this:

>>> import qualified Sel.Hashing.SHA512 as SHA512

Hash

data Hash Source #

A hashed value from the SHA-512 algorithm.

Since: 0.0.1.0

Instances

Instances details
Storable Hash Source #

Since: 0.0.1.0

Instance details

Defined in Sel.Hashing.SHA512

Methods

sizeOf :: Hash -> Int #

alignment :: Hash -> Int #

peekElemOff :: Ptr Hash -> Int -> IO Hash #

pokeElemOff :: Ptr Hash -> Int -> Hash -> IO () #

peekByteOff :: Ptr b -> Int -> IO Hash #

pokeByteOff :: Ptr b -> Int -> Hash -> IO () #

peek :: Ptr Hash -> IO Hash #

poke :: Ptr Hash -> Hash -> IO () #

Show Hash Source #

Since: 0.0.1.0

Instance details

Defined in Sel.Hashing.SHA512

Methods

showsPrec :: Int -> Hash -> ShowS #

show :: Hash -> String #

showList :: [Hash] -> ShowS #

Eq Hash Source #

Since: 0.0.1.0

Instance details

Defined in Sel.Hashing.SHA512

Methods

(==) :: Hash -> Hash -> Bool #

(/=) :: Hash -> Hash -> Bool #

Ord Hash Source #

Since: 0.0.1.0

Instance details

Defined in Sel.Hashing.SHA512

Methods

compare :: Hash -> Hash -> Ordering #

(<) :: Hash -> Hash -> Bool #

(<=) :: Hash -> Hash -> Bool #

(>) :: Hash -> Hash -> Bool #

(>=) :: Hash -> Hash -> Bool #

max :: Hash -> Hash -> Hash #

min :: Hash -> Hash -> Hash #

Display Hash Source #

Since: 0.0.1.0

Instance details

Defined in Sel.Hashing.SHA512

hashToBinary :: Hash -> StrictByteString Source #

Convert a Hash to a binary StrictByteString.

Since: 0.0.1.0

hashToHexText :: Hash -> Text Source #

Convert a Hash to a strict hexadecimal Text.

Since: 0.0.1.0

hashToHexByteString :: Hash -> StrictByteString Source #

Convert a Hash to a strict, hexadecimal-encoded StrictByteString.

Since: 0.0.1.0

Hashing a single message

hashByteString :: StrictByteString -> IO Hash Source #

Hash a StrictByteString with the SHA-512 algorithm.

Since: 0.0.1.0

hashText :: Text -> IO Hash Source #

Hash a UTF8-encoded strict Text with the SHA-512 algorithm.

Since: 0.0.1.0

Hashing a multi-parts message

data Multipart s Source #

Multipart is a cryptographic context for streaming hashing. This API can be used when a message is too big to fit in memory or when the message is received in portions.

Use it like this:

>>> hash <- SHA512.withMultipart $ \multipartState -> do -- we are in MonadIO
...   message1 <- getMessage
...   SHA512.updateMultipart multipartState message1
...   message2 <- getMessage
...   SHA512.updateMultipart multipartState message2

Since: 0.0.1.0

withMultipart Source #

Arguments

:: forall (a :: Type) (m :: Type -> Type). MonadIO m 
=> (forall s. Multipart s -> m a)

Continuation that gives you access to a Multipart cryptographic context

-> m Hash 

Perform streaming hashing with a Multipart cryptographic context.

Use updateMultipart and finaliseMultipart inside of the continuation.

The context is safely allocated and deallocated inside of the continuation.

Since: 0.0.1.0

updateMultipart :: Multipart s -> StrictByteString -> IO () Source #

Add a message portion to be hashed.

This function should be used within withMultipart.

Since: 0.0.1.0