darcs-2.18.5: a distributed, interactive, smart revision control system

Safe Haskell | None
Language | Haskell2010

Darcs.Util.Hash

Synopsis

- newtype Hash = SHA256 ShortByteString
- encodeBase16 :: Hash -> ByteString
- decodeBase16 :: ByteString -> Maybe Hash
- sha256 :: ByteString -> Hash
- sha256strict :: ByteString -> Hash
- sha256sum :: ByteString -> String
- rawHash :: Hash -> ByteString
- mkHash :: ByteString -> Hash
- match :: Maybe Hash -> Maybe Hash -> Bool
- encodeHash :: Hash -> String
- decodeHash :: String -> Maybe Hash
- showHash :: Maybe Hash -> String
- sha1PS :: ByteString -> SHA1
- data SHA1 = SHA1 !Word32 !Word32 !Word32 !Word32 !Word32
- showAsHex :: Word32 -> String
- sha1Xor :: SHA1 -> SHA1 -> SHA1
- sha1zero :: SHA1
- sha1short :: SHA1 -> Word32
- sha1Show :: SHA1 -> ByteString
- sha1Read :: ByteString -> Maybe SHA1

# Documentation

newtype Hash #

Constructors

SHA256 ShortByteString |

#### Instances

Instances details

Read Hash # |
Instance details Defined in Darcs.Util.Hash Methods readsPrec :: Int -> ReadS Hash # readList :: ReadS [Hash] # readPrec :: ReadPrec Hash # readListPrec :: ReadPrec [Hash] #
Show Hash # |
Instance details Defined in Darcs.Util.Hash Methods showsPrec :: Int -> Hash -> ShowS # show :: Hash -> String # showList :: [Hash] -> ShowS #
Eq Hash # |
Instance details Defined in Darcs.Util.Hash Methods (==) :: Hash -> Hash -> Bool # (/=) :: Hash -> Hash -> Bool #
Ord Hash # |
Instance details Defined in Darcs.Util.Hash Methods compare :: Hash -> Hash -> Ordering # (<) :: Hash -> Hash -> Bool # (<=) :: Hash -> Hash -> Bool # (>) :: Hash -> Hash -> Bool # (>=) :: Hash -> Hash -> Bool # max :: Hash -> Hash -> Hash # min :: Hash -> Hash -> Hash #

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 -> Maybe Hash #

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

sha256 :: ByteString -> Hash #

Compute a sha256 of a (lazy) ByteString.

sha256strict :: ByteString -> Hash #

sha256sum :: ByteString -> String #

Same as previous but general purpose.

rawHash :: Hash -> ByteString #

mkHash :: ByteString -> Hash #

match :: Maybe Hash -> Maybe Hash -> Bool #

encodeHash :: Hash -> String #

decodeHash :: String -> Maybe Hash #

showHash :: Maybe Hash -> String #

sha1PS :: ByteString -> SHA1 #

data SHA1 #

Constructors

SHA1 !Word32 !Word32 !Word32 !Word32 !Word32 |

#### Instances

Instances details

Binary SHA1 # |
Instance details Defined in Darcs.Util.Hash Methods put :: SHA1 -> Put # get :: Get SHA1 # putList :: [SHA1] -> Put #
Show SHA1 # |
Instance details Defined in Darcs.Util.Hash Methods showsPrec :: Int -> SHA1 -> ShowS # show :: SHA1 -> String # showList :: [SHA1] -> ShowS #
Eq SHA1 # |
Instance details Defined in Darcs.Util.Hash Methods (==) :: SHA1 -> SHA1 -> Bool # (/=) :: SHA1 -> SHA1 -> Bool #
Ord SHA1 # |
Instance details Defined in Darcs.Util.Hash Methods compare :: SHA1 -> SHA1 -> Ordering # (<) :: SHA1 -> SHA1 -> Bool # (<=) :: SHA1 -> SHA1 -> Bool # (>) :: SHA1 -> SHA1 -> Bool # (>=) :: SHA1 -> SHA1 -> Bool # max :: SHA1 -> SHA1 -> SHA1 # min :: SHA1 -> SHA1 -> SHA1 #

showAsHex :: Word32 -> String #

sha1Xor :: SHA1 -> SHA1 -> SHA1 #

sha1zero :: SHA1 #

sha1short :: SHA1 -> Word32 #

sha1Show :: SHA1 -> ByteString #

sha1Read :: ByteString -> Maybe SHA1 #

Parse a `SHA1` directly from its B16 encoding, given as a `ByteString`, or return `Nothing`. The implementation is quite low-level and optimized because the current implementation of RepoPatchV3 has to read lots of `SHA1` hashes, and profiling showed that this is a bottleneck.