tuupola / trytes
Trytes encoder and decoder for arbitrary data
Requires
- php: ^5.6 || ^7.0
Requires (Dev)
- overtrue/phplint: ^0.2.4
- paragonie/random_compat: ^2.0
- phpunit/phpunit: ^5.7
- squizlabs/php_codesniffer: ^3.0
This package is auto-updated.
Last update: 2024-11-10 05:19:28 UTC
README
This library implements Trytes encoding as described by IOTA project. Trytes are equivalent of bytes but in ternary number system.
Install
Install with composer.
$ composer require tuupola/trytes
Usage
$trytes = new Tuupola\Trytes; $encoded = $trytes->encode(random_bytes(128)); $decoded = $trytes->decode($encoded);
Character sets
By default this library uses the IOTA style character set. Shortcut is provided also for Heptavintimal characters. If required you can use any custom character set of 27 unique characters.
use Tuupola\Trytes; print Trytes::IOTA; /* 9ABCDEFGHIJKLMNOPQRSTUVWXYZ */ print Trytes::HEPTAVINTIMAL; /* 0123456789ABCDEFGHKMNPRTVXZ */ $default = new Trytes(["characters" => Trytes::IOTA]); $heptavintimal = new Trytes(["characters" => Trytes::HEPTAVINTIMAL]); print $default->encode("Hello world!"); /* RBTC9D9DCDEAKDCDFD9DSCFA */ print $heptavintimal->encode("Hello world!"); /* K2N304043451B4346404M361 */
Static Proxy
If you prefer to use static syntax use the provided static proxy.
use Tuupola\TrytesProxy as Trytes; $encoded = Trytes::encode(random_bytes(128)); $decoded = Trytes::decode($encoded);
Testing
You can run tests either manually or automatically on every code change. Automatic tests require entr to work.
$ make test
$ brew install entr $ make watch
Contributing
Please see CONTRIBUTING for details.
Security
If you discover any security related issues, please email tuupola@appelsiini.net instead of using the issue tracker.
License
The MIT License (MIT). Please see License File for more information.