Copyright | (c) Simon Désaulniers 2025 |
---|---|
License | GPL-3 |
Maintainer | sim.desaulniers@gmail.com |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
OpenDHT.InfoHash
Contents
Description
Synopsis
- data InfoHash
- emptyInfoHash :: Dht InfoHash
- randomInfoHash :: Dht InfoHash
- infoHashFromHex :: String -> Dht InfoHash
- infoHashFromBytes :: ByteString -> Dht InfoHash
- infoHashFromString :: String -> Dht InfoHash
- isZero :: InfoHash -> Dht Bool
The data type
This type represents a 160-bit string of bytes consistent with the SHA1 specification.
It is at the heart of this library and is used as arguments for the get/put functions.
Initialization
emptyInfoHash :: Dht InfoHash Source #
Yields the empty InfoHash.
>>>
unDht emptyInfoHash
0000000000000000000000000000000000000000
randomInfoHash :: Dht InfoHash Source #
Computes a random hash.
>>>
unDht randomInfoHash
974b3ea26b91ab5c8155a6cca5c2a3c3a7645f58
infoHashFromHex :: String -> Dht InfoHash Source #
Create an InfoHash from a 40 character hexstring.
>>>
unDht (infoHashFromHex "ffffffffffffffffffffffffffffffffffffffff")
ffffffffffffffffffffffffffffffffffffffff
infoHashFromBytes :: ByteString -> Dht InfoHash Source #
Computes the SHA-1 sum of a given ByteString and yield the resulting InfoHash.
>>>
unDht (infoHashFromBytes (Data.ByteString.Char8.pack "0"))
b6589fc6ab0dc82cf12099d1c2d40ab994e8410c
infoHashFromString :: String -> Dht InfoHash Source #
Computes the SHA-1 sum of a given String and yield the resulting InfoHash.
>>>
unDht (infoHashFromString "0")
b6589fc6ab0dc82cf12099d1c2d40ab994e8410c