| Copyright | (C) Hécate Moonlight 2022 |
|---|---|
| License | BSD-3-Clause |
| Maintainer | The Haskell Cryptography Group |
| Portability | GHC only |
| Safe Haskell | Safe-Inferred |
| Language | Haskell2010 |
Sel.Hashing.SHA512
Description
Synopsis
- data Hash
- hashToBinary :: Hash -> StrictByteString
- hashToHexText :: Hash -> Text
- hashToHexByteString :: Hash -> StrictByteString
- hashByteString :: StrictByteString -> IO Hash
- hashText :: Text -> IO Hash
- data Multipart s
- withMultipart :: forall (a :: Type) (m :: Type -> Type). MonadIO m => (forall s. Multipart s -> m a) -> m Hash
- updateMultipart :: Multipart s -> StrictByteString -> IO ()
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
A hashed value from the SHA-512 algorithm.
Since: 0.0.1.0
Instances
| Storable Hash Source # | Since: 0.0.1.0 |
Defined in Sel.Hashing.SHA512 | |
| Show Hash Source # | Since: 0.0.1.0 |
| Eq Hash Source # | Since: 0.0.1.0 |
| Ord Hash Source # | Since: 0.0.1.0 |
| Display Hash Source # | Since: 0.0.1.0 |
Defined in Sel.Hashing.SHA512 Methods displayBuilder :: Hash -> Builder # displayList :: [Hash] -> Builder # displayPrec :: Int -> Hash -> Builder # | |
hashToBinary :: Hash -> StrictByteString Source #
Convert a Hash to a binary StrictByteString.
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
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
Arguments
| :: forall (a :: Type) (m :: Type -> Type). MonadIO m | |
| => (forall s. Multipart s -> m a) | Continuation that gives you access to a |
| -> 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 #