]> git.mxchange.org Git - core.git/commitdiff
Some rewrites/cleaups
authorRoland Häder <roland@mxchange.org>
Mon, 4 Apr 2011 21:38:29 +0000 (21:38 +0000)
committerRoland Häder <roland@mxchange.org>
Mon, 4 Apr 2011 21:38:29 +0000 (21:38 +0000)
inc/classes/main/rng/class_RandomNumberGenerator.php

index 00eb513fe4f2e9158128fbcaddefc79fad9ba7ff..f656432286755dcf0ea7788eac360348e4b140d5 100644 (file)
@@ -88,7 +88,7 @@ class RandomNumberGenerator extends BaseFrameworkSystem {
 
                // Calculate the extra number which is always the same unless you give
                // a better prime number
-               $this->extraNumber = ($this->prime * $this->prime / (pi() ^ 2));
+               $this->extraNumber = ($this->prime * $this->prime / pow(pi(), 2));
 
                // Seed mt_rand()
                mt_srand((double) sqrt(microtime() * 100000000 * $this->extraNumber));
@@ -105,14 +105,23 @@ class RandomNumberGenerator extends BaseFrameworkSystem {
                // Yet-another fixed salt. This is not dependend on server software or date
                if ($extraInstance instanceof FrameworkInterface) {
                        // With extra instance information
-                       $this->fixedSalt = sha1($serverIp . ':' . $extraInstance->__toString() . ':' . serialize($this->getDatabaseInstance()->getConnectionData()));
+                       $this->fixedSalt = sha1(
+                               $serverIp . ':' .
+                               $extraInstance->__toString() . ':' .
+                               serialize($this->getDatabaseInstance()->getConnectionData())
+                       );
                } else {
                        // Without extra information
                        $this->fixedSalt = sha1($serverIp . ':' . serialize($this->getDatabaseInstance()->getConnectionData()));
                }
 
                // One-way data we need for "extra-salting" the random number
-               $this->extraSalt = sha1($this->fixedSalt . ':' . getenv('SERVER_SOFTWARE') . ':' . $this->getConfigInstance()->getConfigEntry('date_key') . $this->getConfigInstance()->getConfigEntry('base_url'));
+               $this->extraSalt = sha1(
+                       $this->fixedSalt . ':' .
+                       getenv('SERVER_SOFTWARE') . ':' .
+                       $this->getConfigInstance()->getConfigEntry('date_key') . ':' .
+                       $this->getConfigInstance()->getConfigEntry('base_url')
+               );
 
                // Get config entry for max salt length
                $this->rndStrLen = $this->getConfigInstance()->getConfigEntry('rnd_str_length');
@@ -176,7 +185,7 @@ class RandomNumberGenerator extends BaseFrameworkSystem {
        /**
         * Generates a key based on if we have extra (default) or fixed salt enabled
         *
-        * @return      $key    The generated key for encrypion
+        * @return      $key    The generated key for encryption
         */
        public function generateKey () {
                // Default is extra salt