multihash-cryptonite-0.1.0.0: Self-identifying hashes, implementation of <https://github.com/multiformats/multihash>

Copyright2018 Monadic GmbH
LicenseBSD3
Maintainerkim@monadic.xyz, team@monadic.xyz
Stabilityprovisional
Portabilitynon-portable (GHC extensions)
Safe HaskellNone
LanguageHaskell2010

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

Documentation

data Multihash Source #

A multihash-encoded lazy ByteString

Instances
Eq Multihash Source # 
Instance details

Defined in Data.Multihash.Lazy

Ord Multihash Source # 
Instance details

Defined in Data.Multihash.Lazy

NFData Multihash Source # 
Instance details

Defined in Data.Multihash.Lazy

Methods

rnf :: Multihash -> () #

Hashable Multihash Source # 
Instance details

Defined in Data.Multihash.Lazy

fromDigest :: forall a. Multihashable a => Digest a -> Multihash Source #

Encode a Digest as a Multihash.

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.

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 #