# Simple bencoding decode/encode library 🔖
## Install
```python
pip install bencodingpy
```
## Usage
### Decode
```python
>>> from bencodingpy import decode
>>> decode(b'4:spam')
'spam'
>>> decode(b'i1234e')
1234
>>> decode(b'l4:spam4:eggse')
['spam', 'eggs']
>>> decode(b'd4:spaml1:a1:bee ')
{'spam': ['a', 'b']}
>>> with open('debian-12.5.0-amd64-netinst.iso.torrent', 'rb') as file:
... decoded_torrent = decode(file)
... print(decoded_torrent['announce'])
...
http://bttracker.debian.org:6969/announce
```
### Encode
```python
>>> from bencodingpy import encode
>>> encode('spam')
b'4:spam'
>>> encode(1234)
b'i1234e'
>>> encode(['spam', 'eggs'])
b'l4:spam4:eggse'
>>> encode({'spam': ['a', 'b']})
b'd4:spaml1:a1:bee'
```
Raw data
{
"_id": null,
"home_page": null,
"name": "bencodingpy",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": null,
"keywords": "BEP 003, BEP 3, bdecode, bdecoding, bencode, bencoding, bep_003, bittorrent, p2p",
"author": "Abel Garc\u00eda",
"author_email": null,
"download_url": "https://files.pythonhosted.org/packages/91/de/b02f7613b8bb469f1aa2861f2a88f60bc7fad736fb084040c0cbed3f79de/bencodingpy-1.0.1.tar.gz",
"platform": null,
"description": "# Simple bencoding decode/encode library \ud83d\udd16\n\n## Install\n```python\npip install bencodingpy\n```\n\n## Usage\n\n### Decode\n```python\n>>> from bencodingpy import decode\n\n>>> decode(b'4:spam')\n'spam'\n\n>>> decode(b'i1234e')\n1234\n\n>>> decode(b'l4:spam4:eggse')\n['spam', 'eggs']\n\n>>> decode(b'd4:spaml1:a1:bee ')\n{'spam': ['a', 'b']}\n\n>>> with open('debian-12.5.0-amd64-netinst.iso.torrent', 'rb') as file:\n... decoded_torrent = decode(file)\n... print(decoded_torrent['announce'])\n... \nhttp://bttracker.debian.org:6969/announce\n```\n\n### Encode\n```python\n>>> from bencodingpy import encode\n\n>>> encode('spam')\nb'4:spam'\n\n>>> encode(1234)\nb'i1234e'\n\n>>> encode(['spam', 'eggs'])\nb'l4:spam4:eggse'\n\n>>> encode({'spam': ['a', 'b']})\nb'd4:spaml1:a1:bee'\n```",
"bugtrack_url": null,
"license": null,
"summary": "Simple bencoding decode/encode library",
"version": "1.0.1",
"project_urls": {
"Documentation": "https://github.com/abelgarcia2/bencodingpy/readme",
"Issues": "https://github.com/abelgarcia2/bencodingpy/issues",
"Source": "https://github.com/abelgarcia2/bencodingpy"
},
"split_keywords": [
"bep 003",
" bep 3",
" bdecode",
" bdecoding",
" bencode",
" bencoding",
" bep_003",
" bittorrent",
" p2p"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "19f9bbd55d4ceade03a0b27a525bd451f12b1b3231bec972deea59df5fb1a378",
"md5": "c0e2127b6e91a144eee9e10b491806fd",
"sha256": "f17aad46454d5e2c7183793ac66104d928fc9b1ededd897dc9aadabf2dc6f126"
},
"downloads": -1,
"filename": "bencodingpy-1.0.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "c0e2127b6e91a144eee9e10b491806fd",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 17607,
"upload_time": "2024-10-14T19:58:29",
"upload_time_iso_8601": "2024-10-14T19:58:29.576641Z",
"url": "https://files.pythonhosted.org/packages/19/f9/bbd55d4ceade03a0b27a525bd451f12b1b3231bec972deea59df5fb1a378/bencodingpy-1.0.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "91deb02f7613b8bb469f1aa2861f2a88f60bc7fad736fb084040c0cbed3f79de",
"md5": "b27b2e2a7b649168ed716e28bb38b0e6",
"sha256": "9e1fd4f0df3b9eabd3a9c508514a89731ef2a03da6d8d9b5d7cb07ea98f21a27"
},
"downloads": -1,
"filename": "bencodingpy-1.0.1.tar.gz",
"has_sig": false,
"md5_digest": "b27b2e2a7b649168ed716e28bb38b0e6",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 69603,
"upload_time": "2024-10-14T19:58:31",
"upload_time_iso_8601": "2024-10-14T19:58:31.518007Z",
"url": "https://files.pythonhosted.org/packages/91/de/b02f7613b8bb469f1aa2861f2a88f60bc7fad736fb084040c0cbed3f79de/bencodingpy-1.0.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-10-14 19:58:31",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "abelgarcia2",
"github_project": "bencodingpy",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "bencodingpy"
}