bencoding & -decoding library
Project description
yet another… but mine is fast as hell.
install
pip install bcoding
use
from bcoding import bencode, bdecode
decoding:
# decoding from binary files or streams:
with open('some.torrent', 'rb') as f:
torrent = bdecode(f)
print(torrent['announce'])
# decoding from (byte)strings:
one = bdecode(b'i1e')
two = bdecode('3:two')
encoding (note that any iterable or mapping can be bencoded):
# encoding into binary files or streams:
bencode({'a': 0}, sys.stdout.buffer) # ⇒ d1:ai0ee
# encoding to bytestrings:
assert bencode(('a', 0)) == b'l1:ai0ee'
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
bcoding-1.4.tar.gz
(2.9 kB
view details)
File details
Details for the file bcoding-1.4.tar.gz
.
File metadata
- Download URL: bcoding-1.4.tar.gz
- Upload date:
- Size: 2.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c0a76c328486cc1cd4f9d5cde32104d6e0492c20bd2823237354dd9092ad695e |
|
MD5 | 7be09af34523499dcb2a094f7440caf7 |
|
BLAKE2b-256 | 6299a2fda7d0f60de0b0fe77ca2e1b095e5816c16da22e503ae3f5e93b87a778 |