-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
50 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
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; | ||
} |
This file contains 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
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); |