includes/rijndael.php
changeset 287 3370d63928cf
parent 267 105457df35e5
child 300 614f6ff1a855
equal deleted inserted replaced
286:a3ee29133094 287:3370d63928cf
   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/urandom') && is_readable('/dev/urandom') )
   903     if ( @file_exists('/dev/random') && @is_readable('/dev/random') )
   904     {
   904     {
   905       // Let's use something a little more secure
   905       // Let's use something a little more secure
   906       $ur = @fopen('/dev/urandom', 'r');
   906       $ur = @fopen('/dev/random', '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 )