Blogroll

Thursday, October 6, 2011

Create unique Id sercure with hash

have many algorithm to generate to unique Id but almost is popular and the result only containt number
This function allow you to unique Id containt leter and number.
More it provide hash to sercure your unique Id.
Code 
 0) {
                $out -= pow($base, $pad_up);
            }
        }
        $out = sprintf('%F', $out);
        $out = substr($out, 0, strpos($out, '.'));
    } else {
        // Digital number  -->>  alphabet letter code
        if (is_numeric($pad_up)) {
            $pad_up--;
            if ($pad_up > 0) {
                $in += pow($base, $pad_up);
            }
        }

        $out = "";
        for ($t = floor(log($in, $base)); $t >= 0; $t--) {
            $bcp = bcpow($base, $t);
            $a   = floor($in / $bcp) % $base;
            $out = $out . substr($index, $a, 1);
            $in  = $in - ($a * $bcp);
        }
        $out = strrev($out); // reverse
    }

    return $out;
}
]]>
don't worry about code.Parameter: $in = to input to genearate to unique id $to_num =indicate the result return number or leter. $pad_up = tell to number character of unique id. $passKey = to key to hash Example:
 echo rand_uniqid(1012,true,false,'hash1');
This code will be return the unique id with number result.
 echo rand_uniqid(1012,false,7,'hash1');
This code will be return the unique id include leter and number result and unique id have lenght is 7.
Olá! Se você ainda não assinou, assine nosso RSS feed e receba nossas atualizações por email, ou siga nos no Twitter.
Nome: Email:

0 comments:

Post a Comment