2017 © Pedro Peláez
 

library rlp

Recursive Length Prefix Encoding in PHP.

image

web3p/rlp

Recursive Length Prefix Encoding in PHP.

  • Sunday, June 10, 2018
  • by sc0Vu
  • Repository
  • 1 Watchers
  • 6 Stars
  • 716 Installations
  • PHP
  • 3 Dependents
  • 0 Suggesters
  • 3 Forks
  • 2 Open issues
  • 7 Versions
  • 249 % Grown

The README.md

rlp

Recursive Length Prefix Encoding in PHP., (*1)

Build Status codecov Licensed under the MIT License, (*2)

Install

Set minimum stability to dev, (*3)

composer require web3p/rlp

Usage

RLP encode:, (*4)

use Web3p\RLP\RLP;

$rlp = new RLP;
// c483646f67
$encoded = $rlp->encode(['dog']);

// 83646f67
$encoded = $rlp->encode('dog');

RLP decode:, (*5)

use Web3p\RLP\RLP;
use Web3p\RLP\Types\Str;

$rlp = new RLP;
$encoded = $rlp->encode(['dog']);

// only accept 0x prefixed hex string
$decoded = $rlp->decode('0x' . $encoded);

// show 646f67
echo $decoded[0];

// show dog
echo hex2bin($decoded[0]);

// or you can
echo Str::decodeHex($decoded[0]);

API

Web3p\RLP\RLP

encode

Returns recursive length prefix encoding of given inputs., (*6)

encode(mixed $inputs), (*7)

Mixed inputs - array of string, integer or numeric string., (*8)

Note: output is not zero prefixed., (*9)

Example
  • Encode array of string.
use Web3p\RLP\RLP;

$rlp = new RLP;
$encoded = $rlp->encode(['web3p', 'ethereum', 'solidity']);

decode

Returns array recursive length prefix decoding of given data., (*10)

decode(string $input), (*11)

String input - recursive length prefix encoded string., (*12)

Note: output is not zero prefixed., (*13)

Example
  • Decode recursive length prefix encoded string.
use Web3p\RLP\RLP;
use Web3p\RLP\Types\Str;

$rlp = new RLP;
$encoded = $rlp->encode(['web3p', 'ethereum', 'solidity']);
$decoded = $rlp->decode('0x' . $encoded);

// echo web3p
echo hex2bin($decoded[0]);

// echo ethereum
echo hex2bin($decoded[1]);

// echo solidity
echo hex2bin($decoded[2]);

// or you can
echo Str::decodeHex($decoded[0]);
echo Str::decodeHex($decoded[1]);
echo Str::decodeHex($decoded[2]);

License

MIT, (*14)

The Versions

10/06 2018

dev-master

9999999-dev

Recursive Length Prefix Encoding in PHP.

  Sources   Download

MIT

The Development Requires

by Avatar sc0Vu

10/06 2018

0.2.2

0.2.2.0

Recursive Length Prefix Encoding in PHP.

  Sources   Download

MIT

The Development Requires

by Avatar sc0Vu

20/04 2018

0.2.1

0.2.1.0

Recursive Length Prefix Encoding in PHP.

  Sources   Download

MIT

The Development Requires

by Avatar sc0Vu

19/03 2018

v0.2

0.2.0.0

Recursive Length Prefix Encoding in PHP.

  Sources   Download

MIT

The Development Requires

by Avatar sc0Vu

08/03 2018

0.1.2

0.1.2.0

Recursive Length Prefix Encoding in PHP.

  Sources   Download

MIT

The Development Requires

by Avatar sc0Vu

25/02 2018

0.1.1

0.1.1.0

Recursive Length Prefix Encoding in PHP.

  Sources   Download

MIT

The Development Requires

by Avatar sc0Vu

01/02 2018

0.1

0.1.0.0

Recursive Length Prefix Encoding in PHP.

  Sources   Download

MIT

The Development Requires

by Avatar sc0Vu