Metadata-Version: 2.3
Name: bencode2
Version: 0.0.22a4
Summary: A fast and correct bencode serialize/deserialize library
Project-URL: Homepage, https://github.com/trim21/bencode-py
Project-URL: Repository, https://github.com/trim21/bencode-py
Project-URL: Issues, https://github.com/trim21/bencode-py/issues
Author-email: trim21 <trim21me@gmail.com>
License: MIT
License-File: LICENSE
Keywords: bencode,bit-torrent,bittorrent,deserialize,p2p,serialize
Classifier: Development Status :: 5 - Production/Stable
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3 :: Only
Requires-Python: <4.0,>=3.8
Provides-Extra: mypy
Requires-Dist: mypy[mypyc]==1.10.0; (platform_python_implementation == 'CPython') and extra == 'mypy'
Provides-Extra: testing
Requires-Dist: pytest-cov==5.0.0; extra == 'testing'
Requires-Dist: pytest-github-actions-annotate-failures==0.2.0; extra == 'testing'
Requires-Dist: pytest==8.2.1; extra == 'testing'
Description-Content-Type: text/markdown

# A fast and correct bencode serialize/deserialize library

[![PyPI](https://img.shields.io/pypi/v/bencode2)](https://pypi.org/project/bencode2/)
[![tests](https://github.com/trim21/bencode-py/actions/workflows/tests.yaml/badge.svg)](https://github.com/trim21/bencode-py/actions/workflows/tests.yaml)
[![PyPI - Python Version](https://img.shields.io/badge/python-%3E%3D3.8%2C%3C4.0-blue)](https://pypi.org/project/bencode2/)
[![Codecov branch](https://img.shields.io/codecov/c/github/Trim21/bencode-py/main)](https://codecov.io/gh/Trim21/bencode-py/branch/master)

This library is compiled with mypy on cpython, and pure python on pypy.

## install

```shell
pip install bencode2
```

## basic usage

```python
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'
```
