Copyright | (C) Hécate Moonlight 2022 |
---|---|
License | BSD-3-Clause |
Maintainer | The Haskell Cryptography Group |
Portability | GHC only |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
Synopsis
- data Hash
- 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 ()
- hashToBinary :: Hash -> StrictByteString
- hashToHexText :: Hash -> Text
- hashToHexByteString :: Hash -> StrictByteString
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.SHA256 as SHA256
A hashed value from the SHA-256 algorithm.
Since: 0.0.1.0
Instances
Storable Hash Source # | Since: 0.0.1.0 |
Defined in Sel.Hashing.SHA256 | |
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.SHA256 displayBuilder :: Hash -> Builder # displayList :: [Hash] -> Builder # displayPrec :: Int -> Hash -> Builder # |
Hashing a single message
hashByteString :: StrictByteString -> IO Hash Source #
Hash a StrictByteString
with the SHA-256 algorithm.
Since: 0.0.1.0
hashText :: Text -> IO Hash Source #
Hash a UTF8-encoded strict Text
with the SHA-256 algorithm.
Since: 0.0.1.0
Hashing a multi-part 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 <- SHA256.withMultipart $ \multipartState -> do -- we are in MonadIO
... message1 <- getMessage ... SHA256.updateMultipart multipartState message1 ... message2 <- getMessage ... SHA256.updateMultipart multipartState message2
Since: 0.0.1.0
:: 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
within the continuation.
The context is safely allocated first, then the continuation is run and then it is deallocated after that.
Since: 0.0.1.0
updateMultipart :: Multipart s -> StrictByteString -> IO () Source #
Displaying
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