| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Raaz.Hash
Description
This module exposes all the cryptographic hash functions available under the raaz library.
- class (Primitive h, EndianStore h, Encodable h, Eq h, Implementation h ~ SomeHashI h) => Hash h
- hash :: (Hash h, Recommendation h, PureByteSource src) => src -> h
- hashFile :: (Hash h, Recommendation h) => FilePath -> IO h
- hashSource :: (Hash h, Recommendation h, ByteSource src) => src -> IO h
- data HMAC h
- hmac :: (Hash h, Recommendation h, PureByteSource src) => Key (HMAC h) -> src -> HMAC h
- hmacFile :: (Hash h, Recommendation h) => Key (HMAC h) -> FilePath -> IO (HMAC h)
- hmacSource :: (Hash h, Recommendation h, ByteSource src) => Key (HMAC h) -> src -> IO (HMAC h)
- module Raaz.Hash.Sha224
- module Raaz.Hash.Sha256
- module Raaz.Hash.Sha384
- module Raaz.Hash.Sha512
Cryptographic hashes and hmacs.
NOTE: SHA1 is broken.
SHA1 is no more available form this module, its use is highly depreciated. If you want to use it for transition please import Raaz.Hash.Sha1 specifically
Encoding and displaying.
When interfacing with other applications or when printing output to
users, it is often necessary to encode hash, hmac or their keys as
strings. Applications usually present hashes encoded in base16. The
Show and IsString instances for the hashes exposed
here follow this convention.
More generaly, hashes, hmacs and their key are instances of type
class Encodable and can hence can be encoded in
any of the formats supported in raaz.
class (Primitive h, EndianStore h, Encodable h, Eq h, Implementation h ~ SomeHashI h) => Hash h Source #
Type class capturing a cryptographic hash.
Minimal complete definition
Arguments
| :: (Hash h, Recommendation h, PureByteSource src) | |
| => src | Message |
| -> h |
Compute the hash of a pure byte source like, ByteString.
Arguments
| :: (Hash h, Recommendation h) | |
| => FilePath | File to be hashed |
| -> IO h |
Compute the hash of file.
Arguments
| :: (Hash h, Recommendation h, ByteSource src) | |
| => src | Message |
| -> IO h |
Compute the hash of a generic byte source.
The HMAC associated to a hash value. The HMAC type is essentially
the underlying hash type wrapped inside a newtype. Therefore, the
Eq instance for HMAC is essentially the Eq instance for the
underlying hash. It is safe against timing attack provided the
underlying hash comparison is safe under timing attack.
Arguments
| :: (Hash h, Recommendation h, PureByteSource src) | |
| => Key (HMAC h) | |
| -> src | Message |
| -> HMAC h |
Compute the hash of a pure byte source like, ByteString.
Compute the hash of file.
Arguments
| :: (Hash h, Recommendation h, ByteSource src) | |
| => Key (HMAC h) | |
| -> src | Message |
| -> IO (HMAC h) |
Compute the hash of a generic byte source.
Exposing individual hashes.
Individual hash and hmacs are exposed via their respective modules.
These module also export the specialized variants for hashSource,
hash and hashFile for specific hashes. For example, if you are
interested only in say SHA512 you can import the module
Raaz.Hash.Sha512. This will expose the functions sha512Source,
sha512 and sha512File which are specialized variants of
hashSource hash and hashFile respectively for the hash
SHA512. For example, if you want to print the sha512 checksum of
a file, you can use the following.
sha512Checksum :: FilePath -> IO ()
-- print the sha512 checksum of a given file.
sha512Checksum fname = sha512File fname >>= printmodule Raaz.Hash.Sha224
module Raaz.Hash.Sha256
module Raaz.Hash.Sha384
module Raaz.Hash.Sha512