mirror of
https://github.com/OPSnet/bencode-torrent.git
synced 2026-11-07 14:21:07 -10:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fe026fb3a3 | ||
|
|
922a60224d | ||
|
|
a56d7d85c2 |
@@ -1,7 +1,7 @@
|
||||
BEncode Torrent
|
||||
===============
|
||||
|
||||
[](https://github.com/OPSnet/bencode-torrent/actions?query=workflow%3ATest+branch%3Amaster+event%3Apush)
|
||||
[](https://github.com/OPSnet/bencode-torrent/actions/workflows/test.yml)
|
||||
[](https://packagist.org/packages/orpheusnet/bencode-torrent)
|
||||

|
||||
|
||||
@@ -10,24 +10,32 @@ PHP library for encoding and decoding BitTorrent BEncode data, focused around us
|
||||
|
||||
Usage
|
||||
-----
|
||||
|
||||
`composer require orpheusnet/bencode-torrent`
|
||||
|
||||
```php
|
||||
use OrpheusNET\BencodeTorrent;
|
||||
$bencode = new Bencode();
|
||||
require('vendor/autoload.php');
|
||||
$bencode = new \OrpheusNET\BencodeTorrent\BencodeTorrent();
|
||||
$bencode->decodeFile('path/to/file.torrent');
|
||||
var_dump($bencode->getName());
|
||||
var_dump($bencode->getHexInfoHash());
|
||||
var_dump($bencode->getFileList());
|
||||
```
|
||||
|
||||
See the [`BencodeTorrent`](src/BencodeTorrent.php) class for more information on the available methods.
|
||||
Additionally, see [`Bencode`](src/Bencode.php) for the underlying library to encode/decode BEncode data.
|
||||
|
||||
Description
|
||||
-----------
|
||||
|
||||
BEncode is the encoding used by BitTorrent to store and transmitting loosely structured data. It supports
|
||||
BEncode is the encoding used by BitTorrent to store and transmitting loosely structured data. It supports:
|
||||
|
||||
* byte strings
|
||||
* integers
|
||||
* lists
|
||||
* dictionaries (associative arrays, where keys are sorted alphabetically)
|
||||
|
||||
You can see more information about how these types are supported at
|
||||
You can see more information about how these types are supported at
|
||||
[BitTorrentSpecification#Bencoding](https://wiki.theory.org/index.php/BitTorrentSpecification#Bencoding).
|
||||
|
||||
In addition to the above, torrent files are expected to be BEncoded dictionaries that contain minimally the keys
|
||||
@@ -42,6 +50,7 @@ raised. More information on these fields can be found at
|
||||
|
||||
Finally, this library is primarily aimed at being used within the [Gazelle](https://github.com/OPSnet/Gazelle) so
|
||||
we have some utility functions within the library that make sense there to accomplish the following things:
|
||||
|
||||
* Ensuring torrent files are marked as 'private'
|
||||
* Setting a 'source' on torrents (to ensure unique info hash)
|
||||
* Cleaning out unnecessary fields that also reveal stuff about a user (like __announce list__ and __created by__)
|
||||
|
||||
Reference in new issue
Block a user