randhex php code example
Example: randhex php
function random_part() {
return str_pad( dechex( mt_rand( 0, 255 ) ), 2, '0', STR_PAD_LEFT);
}
function randomHEX($amount) {
$_result = "";
for ($i = 0 ; $i < $amount; $i++) {
$_result .= random_part();
}
return $_result;
}
//to get a 16 HEX number
echo randomHEX(8);