Skip to content

Instantly share code, notes, and snippets.

@morontt
Last active July 9, 2020 22:11
Show Gist options
  • Save morontt/43ea349c508a1194a3d9c2baddd2f2a9 to your computer and use it in GitHub Desktop.
Save morontt/43ea349c508a1194a3d9c2baddd2f2a9 to your computer and use it in GitHub Desktop.
ip_addresses_*.txt
<?php
$generator = (function () {
do {
$hash = sha1(microtime());
for ($i = 0; $i < 5; $i++) {
yield sprintf(
'%d.%d.%d.%d',
hexdec(substr($hash, $i * 8, 2)),
hexdec(substr($hash, $i * 8 + 2, 2)),
hexdec(substr($hash, $i * 8 + 4, 2)),
hexdec(substr($hash, $i * 8 + 6, 2))
);
}
} while (true);
})();
$fp = fopen(sprintf('ip_addresses_%d.txt', date('U')), 'w');
$cnt = 0;
while ($cnt < 10000) {
$ip = $generator->current();
fwrite($fp, $ip . "\n");
$generator->next();
$cnt++;
}
fclose($fp);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment