includes/rijndael.php
changeset 44 90b557e7f12c
parent 42 45ebe475ff75
child 45 9cb99e37bfc4
equal deleted inserted replaced
43:30d2fb25afff 44:90b557e7f12c
   868     $key = '';
   868     $key = '';
   869     for($i=0;$i<$len;$i++)
   869     for($i=0;$i<$len;$i++)
   870     {
   870     {
   871       $key .= chr(mt_rand(0, 255));
   871       $key .= chr(mt_rand(0, 255));
   872     }
   872     }
       
   873     if ( file_exists('/dev/urandom') && is_readable('/dev/urandom') )
       
   874     {
       
   875       // Let's use something a little more secure
       
   876       $ur = @fopen('/dev/urandom', 'r');
       
   877       if ( !$ur )
       
   878         return $key;
       
   879       $ukey = @fread($ur, $len);
       
   880       if ( strlen($ukey) != $len )
       
   881         return $key;
       
   882       fclose($ur);
       
   883       return $ukey;
       
   884     }
   873     return $key;
   885     return $key;
   874   }
   886   }
   875   
   887   
   876   /*
   888   /*
   877   function byteArrayToString($arr)
   889   function byteArrayToString($arr)