Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
didlie committed Jan 8, 2018
1 parent 98d4f3d commit efe5660
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 0 deletions.
39 changes: 39 additions & 0 deletions functions.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php
/******* free to use, free to sell, free to change, per developer/owner *****/
/***** MIT License **********************************************************/
function nonce_calculator($difficulty){
$t1 = time();
$a = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
$string = d256($a);
echo "<br>The original string is:: <br>{$string}<br>";
echo "<br><h2>Original Hash:: " . $hash1 = hash("sha1",$string) . "</h2>";
$hash = $hash1;
$zero_string = "";
for($j=$difficulty;$j>0;$j--){
$zero_string .= "0";
}
for($i=0;$i<100000000;$i++){
if(substr($hash,0,$difficulty) === $zero_string){
echo "<br>Time to success: " . (time() - $t1) . " seconds";
die("<br><h1>Success at integer: {$i}</h1>Your hash is: {$hash}");
}
$hash = hash("sha1",$hash . $i);
$denominator = ((int)("1".$zero_string)) - 1;
if(is_int($i/$denominator)) echo "<br>Your hash at integer: {$i}, is: {$hash}";
}

echo "<h2> Your original hash was:: {$hash1}";
}


function d256($a){
$l = strlen($a) - 1;
$s = str_split($a);
$x = "";
for($i=0;$i<256;$i++){
$j = random_int(0,$l);
shuffle($s);
$x .= $s[$j];
}
return $x;
}
11 changes: 11 additions & 0 deletions index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php
/******* free to use, free to sell, free to change, per developer/owner *****/
/***** MIT License **********************************************************/

set_time_limit(300);//required for long calculation times

include "functions.php";//include the functions

$difficulty = 5;//number of zeros that begin the successful hash result

nonce_calculator($difficulty);

0 comments on commit efe5660

Please sign in to comment.