Post
Topic
Board Bitcoin Discussion
Topic OP
Will this code create randstorm vulnerable private key?
by
julia335
on 22/06/2024, 10:05:22 UTC
$file = 'privatekey.txt';
$handle = fopen($file, 'w');

$timestamp = mktime(0, 0, 0, 3, 14, 2012); // Corrected month and day values

for ($i = 0; $i < 86400; $i++) {
    $currentTimestamp = $timestamp + $i;
    mt_srand($currentTimestamp);
    $privateKey = '';
    for ($j = 0; $j < 64; $j++) { // Changed loop variable to $j to avoid overwriting $i
        $privateKey .= dechex(mt_rand(0, 15));
    }
    $data = $privateKey . "\r\n";
    fwrite($handle, $data);
}

fclose($handle); // Close the file handle
echo "Created";