Skip to content

whtsky/bencoder.pyx

Folders and files

NameName
Last commit message
Last commit date

Latest commit

4e28384 · Aug 1, 2016

History

87 Commits
Aug 1, 2016
Jul 31, 2016
Aug 1, 2016
Jul 31, 2016
Jul 31, 2016
Aug 1, 2016
Jan 24, 2016
Jul 31, 2016
Aug 1, 2016
Aug 1, 2016
Aug 1, 2016
Aug 1, 2016
Aug 1, 2016
Aug 1, 2016
Jan 25, 2016
Aug 1, 2016
Aug 1, 2016
Aug 1, 2016

Repository files navigation

Bencoder.pyx

A fast bencode implementation in Cython supports both Python2 & Python3 .

https://img.shields.io/travis/whtsky/bencoder.pyx/master.svg?maxAge=3600&label=macOS https://img.shields.io/appveyor/ci/whtsky/bencoder-pyx/master.svg?maxAge=3600&label=Windows https://img.shields.io/travis/whtsky/bencoder.pyx/master.svg?maxAge=3600&label=wheels

Install

pip install bencoder.pyx

Usage

from bencoder import bencode, bdecode

assert bencode("WWWWWW") == b'6:WWWWWW'
assert bencode(233) == b'i233e'

with open("debian-8.3.0-amd64-netinst.iso.torrent", "rb") as f:
    torrent = bdecode(f.read())
    print(torrent['announce'])

ChangeLog

Version 1.1.2

  • Support encode large int

Version 1.1.0

  • Use OrderedDict instaed of dict
  • Support encoding subclasses of dict