Created
January 6, 2022 05:01
-
-
Save kmark/785ac53e488e54f319811627636f33f6 to your computer and use it in GitHub Desktop.
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
<?php | |
// Quick script to get some not-cryptographically-secure random data | |
// to stdout in a portable way. Useful for generating uncompressable | |
// test files | |
define("INTS_PER_LOOP", 4096); | |
$f = str_repeat("l", INTS_PER_LOOP); | |
$r = []; // Using SplFixedArray is actually slower | |
mt_srand(random_int(PHP_INT_MIN, PHP_INT_MAX)); | |
while (true) { | |
for ($i = 0; $i < INTS_PER_LOOP; $i++) { | |
$r[$i] = mt_rand(); | |
} | |
echo pack($f, ...$r); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment