Benim benzersiz kod ürütme kullandığım yapı;
<?php
header("Content-Type: text/plain; charset=UTF-8");
define("BEGIN_TIME", microtime(true));
function get_random_hash($prefix = null, $toUpper = false) {
$length = 32;
$random_integer = rand(0, PHP_INT_MAX);
$random_string = substr(implode(array_merge(range("a", "z"), range("A", "Z"), range("0", "9"))), 0, $length);
$random_md5_hash = md5(sprintf("-%s-%s-", md5(microtime(true)), date('c')));
$generated_hash = (is_null($prefix)) ? sha1(md5(sha1(sprintf("%s-%s-%s-%s", $random_integer, $random_string, $random_md5_hash, $random_integer)))) : $prefix . sha1(md5(sha1(sprintf("%s-%s-%s-%s", $random_integer, $random_string, $random_md5_hash, $random_integer))));
return ($toUpper) ? strtoupper(substr($generated_hash, 0, $length)) : substr($generated_hash, 0, $length);
}
$generated_hashes = array();
for($i = 0; $i <= 10; ++$i)
$generated_hashes[] = get_random_hash(null, true);
define("END_TIME", microtime(true));
print_r(array(
"begin_time" => BEGIN_TIME,
"end_time" => END_TIME,
"elapsed_time" => (END_TIME - BEGIN_TIME),
"generated_hashes" => $generated_hashes
));