| Copyright | 2018 Monadic GmbH |
|---|---|
| License | BSD3 |
| Maintainer | kim@monadic.xyz, team@monadic.xyz |
| Stability | provisional |
| Portability | non-portable (GHC extensions) |
| Safe Haskell | None |
| Language | Haskell2010 |
Data.Multihash.Lazy
Contents
Description
Like Data.Multihash, but using a lazy ByteString representation.
Example:
>>>:set -XOverloadedStrings>>>import qualified Crypto.Hash as C>>>import Data.ByteArray.Encoding (Base(..), convertToBase)>>>import qualified Data.ByteString as Strict>>>import qualified Data.ByteString.Lazy as Lazy>>>import Data.ByteString.Lazy (toStrict)>>>import qualified Data.ByteString.Char8 as C8>>>import System.IO (stdout)>>>:{let input :: Strict.ByteString input = "multihash" atBase :: Base -> Multihash -> Strict.ByteString atBase base = convertToBase base . toStrict . encodedBytes in C8.hPutStr stdout $ C8.unlines [ atBase Base16 $ multihash C.SHA1 input , atBase Base32 $ multihash C.SHA1 input , atBase Base16 $ multihash C.SHA256 input , atBase Base32 $ multihash C.SHA256 input ] :} 111488c2f11fb2ce392acb5b2986e640211c4690073e CEKIRQXRD6ZM4OJKZNNSTBXGIAQRYRUQA47A==== 12209cbc07c3f991725836a3aa2a581ca2029198aa420b9d99bc0e131d9f3e2cbe47 CIQJZPAHYP4ZC4SYG2R2UKSYDSRAFEMYVJBAXHMZXQHBGHM7HYWL4RY=
Synopsis
- data Multihash
- fromDigest :: forall a. Multihashable a => Digest a -> Multihash
- encodedBytes :: Multihash -> ByteString
- multihash :: (ByteArrayAccess ba, Multihashable a) => a -> ba -> Multihash
- decode :: ByteString -> Either String Multihash
- decodeDigest :: forall a. Multihashable a => ByteString -> Either String (Digest a)
- getMultihash :: Get Multihash
- type Multihashable a = (HashAlgorithm a, FromCryptonite a)
Documentation
A multihash-encoded lazy ByteString
Instances
| Eq Multihash Source # | |
| Ord Multihash Source # | |
| NFData Multihash Source # | |
Defined in Data.Multihash.Lazy | |
| Hashable Multihash Source # | |
Defined in Data.Multihash.Lazy | |
fromDigest :: forall a. Multihashable a => Digest a -> Multihash Source #
encodedBytes :: Multihash -> ByteString Source #
Extract the raw, multihash-encoded bytes of a Multihash.
multihash :: (ByteArrayAccess ba, Multihashable a) => a -> ba -> Multihash Source #
Hash a value to a Multihash.
Note that lazy ByteStrings are not an instance of ByteArrayAccess, ie.
you will have to pass a strict ByteString here.
decode :: ByteString -> Either String Multihash Source #
Decode a Multihash from a lazy ByteString.
decodeDigest :: forall a. Multihashable a => ByteString -> Either String (Digest a) Source #
Decode a Digest from a multihash-encoded lazy ByteString.
Re-exports
type Multihashable a = (HashAlgorithm a, FromCryptonite a) Source #