arokettu/bencode

BitTorrent's Bencode encoder/decoder

Maintainers

👁 arokettu

Package info

github.com/arokettu/bencode

Homepage

Issues

Chat

Documentation

pkg:composer/arokettu/bencode

Statistics

Installs: 18 455

Dependents: 8

Suggesters: 0

Stars: 27

4.3.2 2025-10-09 20:55 UTC

Requires

Suggests

  • php-64bit: Running 64 bit is recommended to prevent integer overflow
  • ext-bcmath: In case you need integers larger than your architecture supports (PHP 8.4 or later)
  • ext-gmp: In case you need integers larger than your architecture supports
  • brick/math: In case you need integers larger than your architecture supports
  • pear/math_biginteger: In case you need integers larger than your architecture supports

Provides

None

Conflicts

None

Replaces

None

MIT 032e827e3c266a23d541afb5d42889288b999fdc

serializebencodebittorrenttorrent


README

👁 Packagist
👁 PHP
👁 Packagist
👁 Gitlab pipeline status
👁 Codecov

Bencode is the encoding used by the peer-to-peer file sharing system BitTorrent for storing and transmitting loosely structured data.

This is a pure PHP library that allows you to encode and decode Bencode data.

Installation

composer require 'arokettu/bencode'

Supported versions:

  • 4.x (current, PHP 8.1+)

Simple use

<?php

\Arokettu\Bencode\Bencode::encode(['info' => ['length' => 12345, 'name' => 'Bencoded demo']]);
\Arokettu\Bencode\Bencode::decode('d4:infod6:lengthi12345e4:name13:Bencoded demoee');

Documentation

Read full documentation here: https://sandfox.dev/php/bencode.html

Documentation for all past major versions can be found on Read the Docs:

Support

Please file issues on our main repo at GitLab: https://gitlab.com/sandfox/bencode/-/issues

Feel free to ask any questions in our room on Gitter: https://gitter.im/arokettu/community

License

The library is available as open source under the terms of the MIT License.