bittorrent-0.0.0.3: Bittorrent protocol implementation.

Portabilityportable
Stabilityexperimental
Maintainerpxqr.sta@gmail.com
Safe HaskellNone

Data.Torrent.InfoHash

Contents

Description

Infohash is a unique identifier of torrent.

Synopsis

Info hash

newtype InfoHash Source

Exactly 20 bytes long SHA1 hash of the info part of torrent file.

Constructors

InfoHash 

Instances

Eq InfoHash 
Ord InfoHash 
Read InfoHash

for hex encoded strings

Show InfoHash

for hex encoded strings

IsString InfoHash

for base16 (hex) encoded strings

ToJSON InfoHash

Represented as base16 encoded string.

FromJSON InfoHash

Can be base16 or base32 encoded string.

Serialize InfoHash 
Hashable.Hashable InfoHash 
URL.URLShow InfoHash 
Pretty InfoHash

base16 encoded.

BEncode InfoHash 

Parsing

textToInfoHash :: Text -> Maybe InfoHashSource

Tries both base16 and base32 while decoding info hash.

Rendering

longHex :: InfoHash -> TextSource

Hex encode infohash to text, full length.

shortHex :: InfoHash -> TextSource

The same as longHex, but 7 character long.

addHashToURI :: URI -> InfoHash -> URISource

Add query info hash parameter to uri.

 info_hash=<url_encoded_info_hash>

hash :: BS.ByteString -> InfoHashSource

Hash strict bytestring using SHA1 algorithm.

hashlazy :: BL.ByteString -> InfoHashSource

Hash lazy bytestring using SHA1 algorithm.