Code: Select all
<?php
function checksumGenerator ($requiredLength = 32) { // declare a default value for the function
$alphabetArray = array(1 => "a", "b", "c", "d", "e", "f", "g", "h", "i", "j",
"k", "l", "m", "n", "o", "p", "q", "r", "s", "t",
"u", "v", "w", "x", "y", "z");
$letterArray = array(1 => 1, 2, 3, 4, 5, 6, 7, 8, 9, 0);
// auto-initialise the var
$checksum = '';
for ($i = 1; $i <= $requiredLength; $i++) {
if (rand(1, 2) === 1) {
// use alphabet
$randomItem = array_rand($alphabetArray, 1);
$checksum .= $alphabetArray[$randomItem];
} else {
// use letter
$randomItem = array_rand($letterArray, 1);
$checksum .= $letterArray[$randomItem];
}
}
return $checksum;
}
?>also what sort of mathematics could i use to find out total possible combinations and collision likelihood, kudos to whoever can provide this
Thanks