IYUUPlus/vendor/rhilip/bencode
2021-02-02 15:48:07 +08:00
..
src 初始化版本库 2021-02-02 15:48:07 +08:00
tests 初始化版本库 2021-02-02 15:48:07 +08:00
.gitignore 初始化版本库 2021-02-02 15:48:07 +08:00
composer.json 初始化版本库 2021-02-02 15:48:07 +08:00
LICENSE 初始化版本库 2021-02-02 15:48:07 +08:00
README.md 初始化版本库 2021-02-02 15:48:07 +08:00

PHP Bencode Library

FOSSA Status

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.

This library is fork from OPSnet/bencode-torrent, with same method like sandfoxme/bencode

Installation

composer require rhilip/bencode

Usage

<?php

require '/path/to/vendor/autoload.php';

use Rhilip\Bencode\Bencode;
use Rhilip\Bencode\ParseErrorException;

// Decodes a BEncoded string
Bencode::decode($string);

// Encodes string/array/int to a BEncoded string
Bencode::encode($data);

// Decodes a BEncoded file From path
Bencode::load($path); 

// Encodes string/array/int to a BEncoded file
Bencode::dump($path, $data); 

// With Error Catch
try {
    Bencode::decode('wrong_string');
 } catch (ParseErrorException $e) {
    // do something
} 

License

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

FOSSA Status