python 3中bittorrent bencoding的快速、安全和非递归实现
flatbencode的Python项目详细描述
在纯python中快速、安全且经过彻底测试的bencode实现 3,没有任何C分机。
这称为flatbencode,因为解码^{tt1}的算法$ 结构是非递归的,因此阻止RuntimeException
用法
>>>fromflatbencodeimportencode,decode>>>encode({b'foo':[b'bar',1]})b'd3:fool3:bari1eee'>>>decode(b'ldei0e0:e')[OrderedDict(),0,b'']
运行测试
$ pip install pytest hypothesis $ py.test -v
变更日志
V0.2.1(2016-10-22)
- 不接受字符串作为字典键[antoine catton]
v0.2.0(2016-10-22)
- 当仍有数据时引发异常[Tim Ruffing,2]
- 使用字节作为python字典键(而不是字符串)[Tim Ruffing,#2]
- 序列化时对字典键排序(遵循BEP-0003)[antoine catton]
v0.1.0(2016-06-12)
- 初次发布
- 可以将bencoding解码为python数据结构。
- 可以将python数据结构编码为bencoding序列化格式。