Created
April 14, 2018 10:57
-
-
Save KennFatt/77e9e282caac16d5f7db09aef24e63ed to your computer and use it in GitHub Desktop.
Randomize-ing with PHP
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 | |
/** | |
* Randomize algorithm. In this case, I tried to random those bytes. | |
* April 14, 2018. | |
* | |
* @author KennFatt | |
*/ | |
$y = ["\xff", "\x00", "\xfe", "\xf3", "\x00"]; | |
$m = []; | |
$x = $y; | |
$n = 4; | |
$i = $n; | |
for ($i; $i > 0; $i--) { | |
$a = random_int(0, count($x) - 1); | |
if (!isset($x[$a])) { | |
$z = array_keys($x); | |
$a = $z[random_int(0, count($z) - 1)]; | |
$m[] = $x[$a]; | |
unset($x[$a]); | |
} else { | |
$m[] = $x[$a]; | |
unset($x[$a]); | |
} | |
} | |
// m |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment