code_junkie

Unique key generation

Nov 10th, 2011
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. strtolower(substr(crypt(time()), 0, 7));
  2.  
  3. strtolower(substr(crypt(uniqid(rand(), true)), 0, 7));
  4.  
  5. $this->password = '';
  6.  
  7. for($i=0; $i<10; $i++)
  8. {
  9. if($i%2 == 0)
  10. $this->password .= chr(rand(65,90));
  11. if($i%3 == 0)
  12. $this->password .= chr(rand(97,122));
  13. if($i%4 == 0)
  14. $this->password .= chr(rand(48,57));
  15. }
  16.  
  17. $ukey = dechex(time()) . crypt( time() . md5(microtime() + mt_rand(0, 100000)) );
  18.  
  19. function GetUniqueValue()
  20. {
  21. static $counter = 0; //initalized only 1st time function is called
  22. return strtr(microtime(), array('.' => '', ' ' => '')) . $counter++;
  23. }
Add Comment
Please, Sign In to add comment