Skip to content

Instantly share code, notes, and snippets.

@askaaqib
Created December 4, 2020 10:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save askaaqib/047454c0c3a5a555331f464dd81fb5fe to your computer and use it in GitHub Desktop.
Save askaaqib/047454c0c3a5a555331f464dd81fb5fe to your computer and use it in GitHub Desktop.
MerkleRoot-From-Repo
<?php
require "../vendor/autoload.php";
$tree = new \Pleo\Merkle\FixedSizeTree(
2,
function($data){
return hash('sha256', hash('sha256', $data, true), true);
},
function($hash) {
echo implode('', unpack('H*', $hash)) . "\n";
}
);
$tree->set(0, 'Science');
$tree->set(1, 'is');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment