Skip to content

Bencode encode/decode library with serialization to/from JSON. Also includes a command-line program.

License

Notifications You must be signed in to change notification settings

z-------------/nim-bencode

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

bencode

This is a Nim library to encode/decode Bencode, the encoding used by the BitTorrent protocol to represent structured data.

Example

import pkg/bencode

let
  data = be({
    "interval": be(1800),
    "min interval": be(900),
    "peers": be("\x0a\x0a\x0a\x05\x00\x80"),
    "complete": be(20),
    "incomplete": be(0),
  })
  bencodedData = bEncode(data)

doAssert bencodedData == "d8:completei20e10:incompletei0e8:intervali1800e12:min intervali900e5:peers6:\x0a\x0a\x0a\x05\x00\x80e"
doAssert bDecode(bencodedData) == data

About

Bencode encode/decode library with serialization to/from JSON. Also includes a command-line program.

Resources

License

Stars

Watchers

Forks

Languages