Skip to content

Instantly share code, notes, and snippets.

@KennFatt
Created April 14, 2018 10:57
Show Gist options
  • Save KennFatt/77e9e282caac16d5f7db09aef24e63ed to your computer and use it in GitHub Desktop.
Save KennFatt/77e9e282caac16d5f7db09aef24e63ed to your computer and use it in GitHub Desktop.
Randomize-ing with PHP
<?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