Last active
December 11, 2015 00:19
-
-
Save JoshuaEstes/4516159 to your computer and use it in GitHub Desktop.
get 20 numbers from a bitcoin transaction hash
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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