Skip to content

Instantly share code, notes, and snippets.

@JoshuaEstes
Last active December 11, 2015 00:19
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 JoshuaEstes/4516159 to your computer and use it in GitHub Desktop.
Save JoshuaEstes/4516159 to your computer and use it in GitHub Desktop.
get 20 numbers from a bitcoin transaction hash
<?php
// get the sha512 hash of the txid and split it by 2
$pool = str_split(hash_hmac('sha512', $txid, $DailySecretKey), 2);
// Loop and get 20
for($N=array(),$i = 0; count($N) < 20 && $i < count($pool); $i++) {
// base 10 that shit
$n = hexdec($pool[$i]);
// make sure it meets the standards
if ($n > 80 || $n < 1) {
// Overkill? maybe
$array = str_split(hash('sha512', $pool[$i]), 2);
array_walk($array, function($v,$k) use(&$pool){
// append to end of array we are pulling out
// numbers from
$pool[] = $v;
});
continue;
}
if (!in_array($n, $N)) {
$N[] = $n;
}
}
var_dump($N); // satoshi picks =D
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment