irwan

Unique random key

Nov 15th, 2011
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.54 KB | None | 0 0
  1. This php script provides a unique random key with 32 characters and can be used to avoid the system to pass some primary keys across the url, by example.
  2.  
  3. function get_cripta()
  4. {
  5.         $year = date('Y');
  6.         $month = date('m');
  7.         $day = date('d');
  8.         $hour = date('H');
  9.         $min = date('i');
  10.         $sec = date('s');
  11.         $coef = rand(1,99999);
  12.         $quo1 = ($year*$month*$day);
  13.         $quo2 = ($hour+$min+$sec);
  14.         $result = ($quo1*$quo2)*$coef;
  15.         $final = md5($result);
  16.         return $final;
  17. }
  18.  
Advertisement
Add Comment
Please, Sign In to add comment