[ create a new paste ] login | about

Link: http://codepad.org/Rk1rxX3V    [ raw code | output | fork ]

aceballos - PHP, pasted on Apr 19:
<?php

# -------------------- [ crypt.php (fragment)

   $arr_ENCODINGCHARS = str_split('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789');
   $int_ENCODINGCHARS = count($arr_ENCODINGCHARS);      

   function newID ($int_SIZEID=32)
      {
      global $arr_ENCODINGCHARS, $int_ENCODINGCHARS; 
      #    
      $real_now = gettimeofday(true); 
      $arr_ip = preg_split('/\./',$_SERVER["HTTP_X_FORWARDED_FOR"] or $_SERVER["REMOTE_ADDR"] or $_SERVER["HTTP_HOST"]);  
      $arr_thisval = array(
	time()-900000000,
	(count($arr_ip) == 4) ? ((((($arr_ip[0] *255)+$arr_ip[1])*255)+$arr_ip[2])*255)+$arr_ip[3] : round(rand(101,7919)),
	floor(rand(101,7919)) % $int_ENCODINGCHARS,
	round(((gettimeofday(true)-$real_now)*1000000) % 1000000)
         );
      for ($i=3; $i>=0; $i--) {
         $int_thisval = $arr_thisval[$i];
         while ($int_thisval) {
            $str_thisID .= $arr_ENCODINGCHARS[$int_thisval % $int_ENCODINGCHARS];
            $int_thisval = floor($int_thisval/$int_ENCODINGCHARS);
            }
         }
      if (strlen($str_thisID)<$int_SIZEID) {
         $str_thisID .= '_';
         while (strlen($str_thisID)<$int_SIZEID)
            { $str_thisID .= $arr_ENCODINGCHARS[floor(rand(0,$int_ENCODINGCHARS))]; }
         }
      return $str_thisID; 
      }

# -------------------- [ CODE

   print NewID();



?>


Output:
1
Hjr9PuAo8L_OiJJGs3AE48y5a2V3lXTn


Create a new paste based on this one


Comments: