Skip to content

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

License

Notifications You must be signed in to change notification settings

theOneDT/Bencode

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PHP Bencode Library

Codacy Badge 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] / [Rhilip/Bencode] (https://github.com/OPSnet/bencode-torrent), with same method like sandfoxme/bencode

Installation

composer require theonedt/bencode

Usage

<?php

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

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

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

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

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

// Encodes string/array/int to a BEncoded file
Bencode::dump(string $path, mixed $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

About

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

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages