A fast and correct bencode serialize/deserialize library
Project description
A fast and correct bencode serialize/deserialize library
introduction
Why yet another bencode package in python?
because I need a bencode library:
- Correct, which mean it should fully validate its inputs,
and won't try decode bencode bytes to
str
by default. Bencode doesn't have a utf-8 str type, only bytes, so many decoder try to decode bytes to str and fallback to bytes, this package won't, it parse bencode bytes value as python bytes. - Fast enough, that's why this package is compiled with cython.
- even cross implement, what's why
this package sill have a pure wheel
bencode2-${version}-py3-none-any.whl
pypi.
install
pip install bencode2
basic usage
import bencode2
assert bencode2.bdecode(b"d4:spaml1:a1:bee") == {b"spam": [b"a", b"b"]}
# If you want to decode dict with str keys:
# Note: this doesn't work with BitTorrent V2 torrent file.
assert bencode2.bdecode(b"d4:spaml1:a1:bee", str_key=True) == {"spam": [b"a", b"b"]}
assert bencode2.bencode({'hello': 'world'}) == b'd5:hello5:worlde'
Decoding
bencode have 4 native types, integer, string, array and directory.
This package will decode integer to int
, array to list
and
directory to dict
.
Because bencode string is not defined as utf-8 string, and will contain raw bytes
bencode2 will decode bencode string to python bytes
.
Encoding
Many python types are supported.
python type | bencode type |
---|---|
bool |
integer 0/1 |
int , enum.IntEnum |
integer |
str , enum.StrEnum |
string |
bytes , bytearray ,memoryview |
string |
list , tuple , NamedTuple |
array |
dict , OrderedDict |
directory |
types.MaapingProxy |
directory |
dataclasses | directory |
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
bencode2-0.2.4.tar.gz
(7.6 kB
view hashes)
Built Distributions
Close
Hashes for bencode2-0.2.4-cp313-cp313-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 91143abfab5ecc1afa95f3c9038df710a1712ff7b658a13c0006ef37ffb2bc9c |
|
MD5 | ca15affa923a7b592504b073803bde02 |
|
BLAKE2b-256 | 33ba5a51483f485a9d80d794f4b756cbb4c3a96bae48bcd529dd2ae5d30be089 |
Close
Hashes for bencode2-0.2.4-cp313-cp313-musllinux_1_2_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 87c8f8e0fc21e4b2aa34adc9e6a4d1b55b8e19edc128fa3eb05f8ce7058f0b94 |
|
MD5 | 7e3841c5cc6034c0b991cd73a6baba5b |
|
BLAKE2b-256 | 7e316492d0a06ce8e31334fdfe8e3836d9b401f199e8780b39c9152ddb67adbc |
Close
Hashes for bencode2-0.2.4-cp313-cp313-musllinux_1_2_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 718790debf9014778e74aa1c2b491024c0bd25318deb3e21504e1c9d04aefbf9 |
|
MD5 | 6b85a12796f35ecf138f01478c823837 |
|
BLAKE2b-256 | fa5b9b97629ca36f6e333f5a69bca94dd8237398aa5f4361eb5d33fdce39550e |
Close
Hashes for bencode2-0.2.4-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ca15d34c925528fd382fb0e9c02c88f9f1108d04ca97f27af0028680704f564a |
|
MD5 | 44810f29f01c204a96d71b917956f88c |
|
BLAKE2b-256 | 7b67cd6809b50be8c6a9222ca7194232c1b39b3f3063de012aabfc20adebbe5f |
Close
Hashes for bencode2-0.2.4-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 23db97bf1a59f9379651c4c58caa5cf64e22978bb427bf27a8662e8352fcbe6a |
|
MD5 | a925bcd2b8fae59b8a144e79b7791862 |
|
BLAKE2b-256 | 9eced0eba99902b73165567e86b24dbd829f59ef03f92f39de1cd598c22543d3 |
Close
Hashes for bencode2-0.2.4-cp313-cp313-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9c2f13d65dcfc65675515b927728390ee3e18edbf0202de8de07028d60a11f1d |
|
MD5 | b28f0eb3b894c477bc602c5d56ee85fc |
|
BLAKE2b-256 | 6224a486685c7e18af88c7a31d79293539ac976fc1a03fd27017bd0d2e59c499 |
Close
Hashes for bencode2-0.2.4-cp313-cp313-macosx_10_13_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b06f69eaba0307f93d5567ab6d434226a802e9368f3bbadcbb40d1b42f6ec637 |
|
MD5 | cbdb72beaaab352731bfcff88d319f7b |
|
BLAKE2b-256 | cfe8adb7940fe59840a4e3305e66d4089a50e934fb79cbf76cef0afa7351aad5 |
Close
Hashes for bencode2-0.2.4-cp312-cp312-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 350e98b29ce52213c84a20eb5d160c17bb3a9155e76befc602685edaa3dcf1a4 |
|
MD5 | 2f03c730ab60cc0f117b8dd8ffb21482 |
|
BLAKE2b-256 | f5ccd7651800a97381a53c5e2c6664edb65ee6e7ee1df1ffd2eb88ee9856fbc0 |
Close
Hashes for bencode2-0.2.4-cp312-cp312-musllinux_1_2_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1ca24e83b474bb73563d506df664effae2f827e7b227e241def913d651f41ecb |
|
MD5 | bb24b0df9968e24faf9d8b67af16f913 |
|
BLAKE2b-256 | feb90f2b5e03ebc42b2ec89b0624546dac4e94bed8962e6f458eb87a406d8fde |
Close
Hashes for bencode2-0.2.4-cp312-cp312-musllinux_1_2_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a8a3e156b1839a8c41e64032fa5c0f3304075adefb810882bc8fd453c9e614cd |
|
MD5 | 32b8bf2223a3d69b5a8f321786cf44a1 |
|
BLAKE2b-256 | 2b7850b17533cc8af44a50fb16d46a0679b036bd01ad2be0ccb184eb1258353f |
Close
Hashes for bencode2-0.2.4-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 94ac74cc95233645e847a184a8725f15e2d5036ee0ddfd85c23c59ae104a7082 |
|
MD5 | 7274eca530cffc287677e65c06465f12 |
|
BLAKE2b-256 | 30b229917a77506dadd40b8851e0b3239dae588bb5f48877027a3eb4925c47ab |
Close
Hashes for bencode2-0.2.4-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 741e2d4caeba9a77ace5d8de4f0dc1495e82b9ffb0f0dbc016c289ed964c6d84 |
|
MD5 | a1fd1e82621d87236c1fd1390869e247 |
|
BLAKE2b-256 | f843a7a835d64bac01a947dbaf05de18d297b21b92cef9ec04a90c7bfe70676f |
Close
Hashes for bencode2-0.2.4-cp312-cp312-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 56e4fd8ea6e84d252fc0e9c38b63ad3c520a594b8dfd488a3dc80932bb4a5e25 |
|
MD5 | 27ee8b8359a8c7739901fc517b8c1998 |
|
BLAKE2b-256 | 2760875019534f40cedb1dc8bb005b9f4fe024fd19467426a3394ead2ac06d6b |
Close
Hashes for bencode2-0.2.4-cp312-cp312-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e0795e63508a8e2025b949fbd6e5556496d5055d013f2b4d55291346b80d2c51 |
|
MD5 | ea269989ed0b2f6e4e7e7fe17aa22ae3 |
|
BLAKE2b-256 | 1be15a86e6ce29336b08d76d778372a1f8526c36cf8ad6070ef4cb1dc8fa6bcc |
Close
Hashes for bencode2-0.2.4-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 421ec739e6a944abd601a82c52a3599644c799b6f35181e0754ff394d57e5a03 |
|
MD5 | 0e69ee2ddf68341584b30961a0ec2587 |
|
BLAKE2b-256 | 79ca4e05ed41859039fa7b1dde01af59ea1bb46ccb58517d435a61ef26b0579a |
Close
Hashes for bencode2-0.2.4-cp311-cp311-musllinux_1_2_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d1d8b8fd242dd60fa0d32a11c6e87ed1ae16da16cdcb3fea88e943adcc4b9e69 |
|
MD5 | e0326f7cce467c01393b4f8c9b10aece |
|
BLAKE2b-256 | 4b9ea20189bf9c4ba36ee97a6144c26332650a81910efb52308356c3ee3914b0 |
Close
Hashes for bencode2-0.2.4-cp311-cp311-musllinux_1_2_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | af83a27db1d2071bc44e52e26cba63229b75ae21e11634c4a652ad1c092c09d1 |
|
MD5 | 0b2651082e4c7b4c5cbdd9a46af59182 |
|
BLAKE2b-256 | 64dfe508c0fd5963536b13d9b3f5a90397c52621e2a3e2cd77129bdfe0741f43 |
Close
Hashes for bencode2-0.2.4-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 63dcf7d30e7da6d4e54defdd979efe470498978d37787515b93cb1f42903e2ec |
|
MD5 | 6d2a43d82080c84927450f8f9c2d8c21 |
|
BLAKE2b-256 | bb568ef5f77d521ce84d90b4578a6daca49e136e82c15881e5af36b11ce3fb57 |
Close
Hashes for bencode2-0.2.4-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 891315717a4b1bff0583d93488ab130f06d6930a284d88a19681f90ac7cc1193 |
|
MD5 | 55f7a29bee4f2e5d93fb354d60f88653 |
|
BLAKE2b-256 | 999337abef78808c7f15cc477d6070a53b862eae2da5156d70aeda535f6d87c6 |
Close
Hashes for bencode2-0.2.4-cp311-cp311-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b4627e41f595eb3362572f86b789e6c23d9752fc829024ce77e00d35976a582c |
|
MD5 | c50e7728fc4d0fcbe7bf944d6fda1f1b |
|
BLAKE2b-256 | ceaedfed83bfec0afa5e34b37495e67a271c1b981146f2e8305215e4e5a03c9f |
Close
Hashes for bencode2-0.2.4-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e63add898bef8889e8d1042a03c0c98b7d83bb4acf09905d227146d8e40dc511 |
|
MD5 | 10160b995775d1ccced655c65b89cc25 |
|
BLAKE2b-256 | 8b1b355c193b81f93dd7cad8424c6804a11ef20a130f586736272d31829e7ab6 |
Close
Hashes for bencode2-0.2.4-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 97b8e5943da5d7fb6bd0cfefb1b43e3b312d0d826b11bc9081cb3fb0840eb627 |
|
MD5 | 76822c3eac49c1a83f00dc5cd7ce2157 |
|
BLAKE2b-256 | 4bfd7d9c786f41be21720433a9e23c863e6a47e98066d8b11793ab076ee67d94 |
Close
Hashes for bencode2-0.2.4-cp310-cp310-musllinux_1_2_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 21482db96aed040091b786c19b984a68962879bacbeff1e7ed62d92ccf5ba374 |
|
MD5 | 5f344cd9de318492250e633767b589c8 |
|
BLAKE2b-256 | 35788c9a99b893014ae72cd08c469b171e24a8dc32634c739bc87cd2b2cd5b4a |
Close
Hashes for bencode2-0.2.4-cp310-cp310-musllinux_1_2_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5878ab127c9dc46d0473f655dabab8cc8178b976401f805a00243f9b3b29e158 |
|
MD5 | 06ee35bedf1a0047997d28b243875237 |
|
BLAKE2b-256 | 6509597199b65b1e591a393608645965d6d75cf306a6757dd6c13df750d62828 |
Close
Hashes for bencode2-0.2.4-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 86b445f9440b4e95e59e484e880ae0a2fb7f1c85f6409415af45e55ffc18f0ea |
|
MD5 | 13af138299fae378aac17a0e60b1eacf |
|
BLAKE2b-256 | 5a16d8c0aade17775e8cd16e616f059b19b0f335e2b5c390329752b8fcf056bf |
Close
Hashes for bencode2-0.2.4-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 54ef9aae497b2d3bff1dba5f36134c07ad0001056c905d976699c2e082908f56 |
|
MD5 | 3b7b3dfc13d44cf564118050f5976e2c |
|
BLAKE2b-256 | ed6de954e28fdf5d3571c69599c9bda714c1bc95b91075049dcae5c9692ad44c |
Close
Hashes for bencode2-0.2.4-cp310-cp310-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 81f00b70d52332de1297b299eaf88ccac04eb7034a4eae740c8d4ea390bb67e2 |
|
MD5 | 407cae0a045b7d70f644b2624722de11 |
|
BLAKE2b-256 | 32ede6a1c1f65e99bdf9ff6aaec190f0c82fa217019c168b3576f4a3a8fcac64 |
Close
Hashes for bencode2-0.2.4-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a03581fa251647e5e53192fc4db1e921cb9bceda58db2a79628f53b7a0a9306f |
|
MD5 | fbd47c1386f88c2d225ff67fc278f913 |
|
BLAKE2b-256 | 80ce5de3e601b06a078d6e383ca8fe7a3bb1cbcaa9e0ec218f1370187d5f4316 |
Close
Hashes for bencode2-0.2.4-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a4fd6a890a01b8ebd10905420fb4502683fde1c35ff2e6c64266bc80fe82d879 |
|
MD5 | 24a4b6043733002bf6f281e6de226978 |
|
BLAKE2b-256 | 14a8a11f2cb96514a8fa74401c93feac64e39f039f822e4dfa9c287e38afd346 |
Close
Hashes for bencode2-0.2.4-cp39-cp39-musllinux_1_2_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3df8e107641e6dcd5b5355962a843e0877217d400974e38181a4e0a5e54129e2 |
|
MD5 | 1dbd056a8a49df0b9558254362fb9f28 |
|
BLAKE2b-256 | 5d9ab87f58373bcbf64440e941b5baad0d3e682669364a1c25a30950eba2c36b |
Close
Hashes for bencode2-0.2.4-cp39-cp39-musllinux_1_2_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 703befaf37e3c92d13d2fa51f1f20be78b143b2dcde822efc4a1b4186c967861 |
|
MD5 | e918ff466a0ab4f5975d26adc3e5da3a |
|
BLAKE2b-256 | 70e9f959eeeb23afaa7e5a0c6d2ed5daa8bce81d1c6c36bf9b80ba8373e049b7 |
Close
Hashes for bencode2-0.2.4-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0e6a2f50c02916ebb43d36365c8b356021487ce61389c74822e08e0990534460 |
|
MD5 | 6eba72ac0b13de2bed676fae3b93b49a |
|
BLAKE2b-256 | bcf010fb39db18b0e7b46f92a43c4e6ee781baf5992c27b70447d4b6740db12e |
Close
Hashes for bencode2-0.2.4-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 158fb8c65dbf0857c3f10ab7137444dabd3140fd328bcfdd29ed7d8b79da828c |
|
MD5 | 53a597a08a24596bfbde1af19a0e258e |
|
BLAKE2b-256 | f020b097f5bd8ef0da1c190cc98656213b8ecfee5d0c5e229759fdd515557da8 |
Close
Hashes for bencode2-0.2.4-cp39-cp39-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cc1505655d1a6a436f927af150d0c9ab128c47c5c5cc28f4d2a5a0a3d6aca36a |
|
MD5 | 7d72a94af0f2d3f388c8d8cf2464240c |
|
BLAKE2b-256 | 5d561a9dcc17225337148f6f87b08f29b1b92af3cf3bd83c945fd487bd9cf27c |
Close
Hashes for bencode2-0.2.4-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3af0d3c147d700e787d1118360a2faced3d6533f57e10b60f8aa7dba87ae033f |
|
MD5 | 0537320532e9421db5a581901a612be7 |
|
BLAKE2b-256 | c8535f84e09b4e172edb3561b13298a703c4f11734c2f195379249a4640d8d6b |
Close
Hashes for bencode2-0.2.4-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4dc5f3b015ce821529f13f8b09b8a6edd9c483c5447bcd3e724aa2736f4ea9b9 |
|
MD5 | 19d737b21cda103b9607373b28367acf |
|
BLAKE2b-256 | 74444480d112e86c2574641cbef22bad51b4bb67895edc6763a9c3d75867c25f |
Close
Hashes for bencode2-0.2.4-cp38-cp38-musllinux_1_2_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e046109c92c14397ac4fdeec61ce093ddbecf37183d2c72a81233fcf5b5ed3c9 |
|
MD5 | 9ff9f19c846263217e49ab86d6022773 |
|
BLAKE2b-256 | 4b5efaf47b4758cf3368de5d87c04b51607d124f4766012a3dbe90307711413f |
Close
Hashes for bencode2-0.2.4-cp38-cp38-musllinux_1_2_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7a3a57fc4815c8aa175cb0d19d308971286927d00ef8c317c3df7b56d8c9aca0 |
|
MD5 | 66a619a84b08f8f3e2b3bbdb51094604 |
|
BLAKE2b-256 | 016c1689a7e7d930dad6070db7828d5752774205d070f562d9aa897a139f939a |
Close
Hashes for bencode2-0.2.4-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3576bbd9913895251f8f133165c526bdf180475de88c1c21fcd8de052fa03300 |
|
MD5 | fabb64ebd7c44d5f57cbb94173d26cc3 |
|
BLAKE2b-256 | a87f6a999429bf5375058d5cba1f86cda5dfc331376134be45c79067d021b537 |
Close
Hashes for bencode2-0.2.4-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8279e25dff661618c7c40b54df3195e7a6b651af029d8d08a5fa4582e86ebd91 |
|
MD5 | 515d14c9a7227affb20c15ee5f730ef3 |
|
BLAKE2b-256 | c33c46a82e3ddb992e9d27f6eace61764709761f3271a2850318033ff7c636e1 |
Close
Hashes for bencode2-0.2.4-cp38-cp38-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8c676ff7933d07cc25fa73055608c75faced1afc501cbbbe293945233c7ecf51 |
|
MD5 | 436e6f6711981546d834503f7251f14e |
|
BLAKE2b-256 | d998f7a7c9e30da7e084bfe87de3336fba093decc698a1b74053e074d4bf2193 |
Close
Hashes for bencode2-0.2.4-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 468084af5b0102330a91dbc16b0a2c030d35e828bfdcc9c99ed9d33748920fb3 |
|
MD5 | 83fec7ebf79654185efafd24834a1d93 |
|
BLAKE2b-256 | dfd4199922df614983915c32884f578dcda47b46584ea9ef22bc4b5bb140e3ab |