PHPackages                             rhilip/bencode - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. rhilip/bencode

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

rhilip/bencode
==============

A pure and simple PHP library for encoding and decoding Bencode data

v2.5.3(4mo ago)4024.1k↓35.7%62MITPHPPHP ^7.3|&gt;=8.0CI passing

Since Jan 22Pushed 4mo ago4 watchersCompare

[ Source](https://github.com/Rhilip/Bencode)[ Packagist](https://packagist.org/packages/rhilip/bencode)[ RSS](/packages/rhilip-bencode/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (1)Versions (24)Used By (2)

PHP Bencode Library
===================

[](#php-bencode-library)

[![Codacy Badge](https://camo.githubusercontent.com/90b96ebeba011836de631805ea54cb74b9da0c7526d3b2a7c695dbc2a213209a/68747470733a2f2f6170692e636f646163792e636f6d2f70726f6a6563742f62616467652f47726164652f3134626239353235613561333433303739653435643935303164616331623463)](https://app.codacy.com/manual/rhilipruan/Bencode?utm_source=github.com&utm_medium=referral&utm_content=Rhilip/Bencode&utm_campaign=Badge_Grade_Dashboard)[![FOSSA Status](https://camo.githubusercontent.com/8f9199f3da14a7ec2c1fccbccbc3aaf024308f4c047e9d44ef7a58d1e9c46740/68747470733a2f2f6170702e666f7373612e696f2f6170692f70726f6a656374732f6769742532426769746875622e636f6d2532465268696c697025324642656e636f64652e7376673f747970653d736869656c64)](https://app.fossa.io/projects/git%2Bgithub.com%2FRhilip%2FBencode?ref=badge_shield)

[Bencode](https://en.wikipedia.org/wiki/Bencode) is the encoding used by the peer-to-peer file sharing system [BitTorrent](https://opensource.org/licenses/MIT) for storing and transmitting loosely structured data.

This is a pure PHP library that allows you to encode and decode Bencode data, with torrent file parse and vaildate.

This library is forked from [OPSnet/bencode-torrent](https://github.com/OPSnet/bencode-torrent), with almost same methods like [arokettu/bencode](https://github.com/arokettu/bencode), [arokettu/torrent-file](https://github.com/arokettu/torrent-file)

Installation
------------

[](#installation)

```
composer require rhilip/bencode
```

if you don't use `Rhilip\Bencode\TorrentFile` class, you can specific version to `1.x.x`and if your PHP version is `5.6` or `7.0-7.2`, please stop at version `1.2.0` and `2.0.0`

```
composer require rhilip/bencode:1.2.0
```

**The only Break Change is `ParseErrorException` in `1.x.x` rename to `ParseException` in `2.x.x`.**

Usage
-----

[](#usage)

### Class `Rhilip\Bencode\Bencode`

[](#class-rhilipbencodebencode)

A pure PHP class to encode and decode Bencode data from file path and string.

```
