includes/rijndael.php
changeset 305 04f8250583e5
parent 300 614f6ff1a855
equal deleted inserted replaced
304:fc42bccc65e5 305:04f8250583e5
   898     $key = '';
   898     $key = '';
   899     for($i=0;$i<$len;$i++)
   899     for($i=0;$i<$len;$i++)
   900     {
   900     {
   901       $key .= chr(mt_rand(0, 255));
   901       $key .= chr(mt_rand(0, 255));
   902     }
   902     }
   903     if ( @file_exists('/dev/random') && @is_readable('/dev/random') )
   903     if ( @file_exists('/dev/urandom') && @is_readable('/dev/urandom') )
   904     {
   904     {
   905       // Let's use something a little more secure
   905       // Let's use something a little more secure
   906       $ur = @fopen('/dev/random', 'r');
   906       $ur = @fopen('/dev/urandom', 'r');
   907       if ( !$ur )
   907       if ( !$ur )
   908         return $key;
   908         return $key;
   909       $ukey = @fread($ur, $len);
   909       $ukey = @fread($ur, $len);
   910       fclose($ur);
   910       fclose($ur);
   911       if ( strlen($ukey) != $len )
   911       if ( strlen($ukey) != $len )