hashed-storage-0.5.10: Hashed file storage support code.

Safe HaskellNone

Storage.Hashed.Hash

Synopsis

Documentation

data Hash

Constructors

SHA256 !ByteString 
SHA1 !ByteString 
NoHash 

Instances

Eq Hash 
Data Hash 
Ord Hash 
Read Hash 
Show Hash 
Typeable Hash 

encodeBase64u :: Hash -> ByteString

decodeBase64u :: ByteString -> Hash

Take a base64/url-encoded string and decode it as a Hash. If the string is malformed, yields NoHash.

encodeBase16 :: Hash -> ByteString

Produce a base16 (ascii-hex) encoded string from a hash. This can be turned back into a Hash (see decodeBase16. This is a loss-less process.

decodeBase16 :: ByteString -> Hash

Take a base16-encoded string and decode it as a Hash. If the string is malformed, yields NoHash.

sha256 :: ByteString -> Hash

Compute a sha256 of a (lazy) ByteString. However, although this works correctly for any bytestring, it is only efficient if the bytestring only has a sigle chunk.

rawHash :: Hash -> ByteString

match :: Hash -> Hash -> Bool