sandfoxme/bencode

BitTorrent's Bencode encoder/decoder

3.0.0 2021-09-17 02:28 UTC

README

Packagist Packagist Gitlab pipeline status Codecov
PHP PHP PHP

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 'sandfoxme/bencode'

Supported versions:

  • Version 1.x supports PHP 7.0 and later
  • Version 2.x supports PHP 8.0 and later and has slightly better error handling
  • Version 3.x supports PHP 8.1 and later and is a bit stricter about data type handling

Simple use

<?php

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

Documentation

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

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

Support

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

License

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