这是一个无限循环。有没有不使用类直接解决的方法?

问题描述 投票:0回答:1
<?php

$file = 'privatekey.txt';
$handle = fopen($file, 'w');

for ($v1 = 78457163725914333419136; $v1 <= 78457163725914333419136+10; $v1++) {
    $randomWord = $v1;  
    $hash = hash('sha256', $randomWord);
    $data = $hash . "\r\n";
    fwrite($handle, $data);
}

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

?>

这是一个无限循环。有没有不使用类直接解决的方法?

php
1个回答
0
投票
<?php

$file = 'privatekey.txt';
$handle = fopen($file, 'w');

$start = '78457163725914333419136';
$end = '78457163725914334419146'; // 10 more than start

for ($v1 = $start; bccomp($v1, $end) <= 0; $v1 = bcadd($v1, '1')) {
    $hash = hash('sha256', $v1);
    $data = $hash . "\r\n";
    fwrite($handle, $data);
}

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

?>
© www.soinside.com 2019 - 2024. All rights reserved.