includes/rijndael.php
changeset 44 90b557e7f12c
parent 42 45ebe475ff75
child 45 9cb99e37bfc4
--- a/includes/rijndael.php	Thu Jul 05 10:43:03 2007 -0400
+++ b/includes/rijndael.php	Thu Jul 05 10:50:35 2007 -0400
@@ -870,6 +870,18 @@
     {
       $key .= chr(mt_rand(0, 255));
     }
+    if ( file_exists('/dev/urandom') && is_readable('/dev/urandom') )
+    {
+      // Let's use something a little more secure
+      $ur = @fopen('/dev/urandom', 'r');
+      if ( !$ur )
+        return $key;
+      $ukey = @fread($ur, $len);
+      if ( strlen($ukey) != $len )
+        return $key;
+      fclose($ur);
+      return $ukey;
+    }
     return $key;
   }