cryptohash-conduit-0.1.1/0000755000000000000000000000000012315734105013527 5ustar0000000000000000cryptohash-conduit-0.1.1/cryptohash-conduit.cabal0000644000000000000000000000204712315734105020345 0ustar0000000000000000Name: cryptohash-conduit Version: 0.1.1 Synopsis: cryptohash conduit Description: Support all the @cryptohash@ package using conduits from the @conduit@ package. License: BSD3 License-file: LICENSE Copyright: Vincent Hanquez Author: Vincent Hanquez Maintainer: vincent@snarc.org Category: Cryptography, Conduit Stability: experimental Build-Type: Simple Homepage: http://github.com/vincenthz/hs-cryptohash-conduit Cabal-Version: >=1.8 Extra-source-files: README.md Library Exposed-modules: Crypto.Hash.Conduit Build-depends: base >= 4 && < 5 , bytestring , conduit , resourcet , conduit-extra , cryptohash , transformers ghc-options: -Wall -fwarn-tabs source-repository head type: git location: git://github.com/vincenthz/hs-cryptohash-conduit cryptohash-conduit-0.1.1/README.md0000644000000000000000000000021512315734105015004 0ustar0000000000000000cryptohash-conduit ================== Documentation: [cryptohash-conduit on hackage](http://hackage.haskell.org/package/cryptohash-conduit) cryptohash-conduit-0.1.1/Setup.hs0000644000000000000000000000005612315734105015164 0ustar0000000000000000import Distribution.Simple main = defaultMain cryptohash-conduit-0.1.1/LICENSE0000644000000000000000000000272212315734105014537 0ustar0000000000000000Copyright (c) 2014 Vincent Hanquez All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. Neither the name of the author nor the names of his contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. cryptohash-conduit-0.1.1/Crypto/0000755000000000000000000000000012315734105015007 5ustar0000000000000000cryptohash-conduit-0.1.1/Crypto/Hash/0000755000000000000000000000000012315734105015672 5ustar0000000000000000cryptohash-conduit-0.1.1/Crypto/Hash/Conduit.hs0000644000000000000000000000312412315734105017633 0ustar0000000000000000{-# LANGUAGE RankNTypes, BangPatterns #-} -- | -- Module : Crypto.Hash.Conduit -- License : BSD-style -- Maintainer : Vincent Hanquez -- Stability : experimental -- Portability : unknown -- -- A module containing Conduit facilities for hash based functions. -- -- this module is vaguely similar to the crypto-conduit part related to hash -- on purpose, as to provide an upgrade path. The api documentation is pulled -- directly from this package and adapted, and thus are originally -- copyright Felipe Lessa. -- module Crypto.Hash.Conduit ( -- * Cryptographic hash functions sinkHash , hashFile ) where import Crypto.Hash import qualified Data.ByteString as B import Data.Conduit import Data.Conduit.Binary (sourceFile) import Control.Monad.IO.Class (MonadIO, liftIO) import Control.Monad.Trans.Resource (runResourceT) -- | A 'Sink' that hashes a stream of 'B.ByteString'@s@ and -- creates a digest @d@. sinkHash :: (Monad m, HashAlgorithm hash) => Consumer B.ByteString m (Digest hash) sinkHash = sink hashInit where sink ctx = do b <- await case b of Nothing -> return $! hashFinalize ctx Just bs -> sink $! hashUpdate ctx bs -- | Hashes the whole contents of the given file in constant -- memory. This function is just a convenient wrapper around -- 'sinkHash' defined as: -- -- @ -- hashFile fp = 'liftIO' $ 'runResourceT' ('sourceFile' fp '$$' 'sinkHash') -- @ hashFile :: (MonadIO m, HashAlgorithm hash) => FilePath -> m (Digest hash) hashFile fp = liftIO $ runResourceT (sourceFile fp $$ sinkHash)