danny50610 / php-cid
Installs: 1 885
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 0
Requires
- php: ^7.4|^8.0
- tuupola/base58: ^2.1
Requires (Dev)
- phpunit/phpunit: ^9.5
This package is auto-updated.
Last update: 2024-10-19 19:21:12 UTC
README
Example
use Danny50610\Cid\CID; use Danny50610\Cid\Codec; use Danny50610\Cid\Multihash; use Danny50610\Cid\MultihashType; // true for binary $hash = hash('sha256', 'The quick brown fox jumped over the lazy dog.', true); $type = MultihashType::get('sha2_256'); // v0 $multihash = new Multihash($type, $hash); $cidv0 = CID::makeV0($multihash); print($cidv0 . PHP_EOL); // QmVPKnh2nScP7zfMWFEC6JAcruqxPncbMmAMa98AiMZCZQ // v1 $cidv1 = new CID(1, Codec::get('DagProtobuf'), $type, $hash); print($cidv1 . PHP_EOL); // zdj7WcUaA86dv5yzhyHEzBoxg1BV83Q7L2jE5ZtEwWqXo86jL