]> git.mxchange.org Git - shipsimu.git/blobdiff - inc/classes/main/rng/class_RandomNumberGenerator.php
Update of last activitity and action in user added, refresh of auth cookies added
[shipsimu.git] / inc / classes / main / rng / class_RandomNumberGenerator.php
index 12e1c01820925c40bc87efe88f383c6881d8044a..2439ffb2c1d614c856ff12745a0aec9aa25a54fb 100644 (file)
@@ -37,6 +37,11 @@ class RandomNumberGenerator extends BaseFrameworkSystem {
         */
        private $extraSalt = "";
 
+       /**
+        * Fixed salt for secured hashing
+        */
+       private $fixedSalt = "";
+
        /**
         * Maximum length for random string
         */
@@ -102,11 +107,14 @@ class RandomNumberGenerator extends BaseFrameworkSystem {
                if ($this->getConfigInstance()->readConfig('is_single_server') == "Y") {
                        // Then use that IP for extra security
                        $serverIp = getenv('SERVER_ADDR');
-               }
+               } // END - if
+
+               // Yet-another fixed salt. This is not dependend on server software or date
+               $this->fixedSalt = sha1($serverIp . ":" . serialize($this->getDatabaseInstance()->getConnectionData()));
 
                // One-way data we need for "extra-salting" the random number
                /* @TODO Add site key for stronger salt! */
-               $this->extraSalt = sha1($serverIp . ":" . getenv('SERVER_SOFTWARE') . ":" . $this->getConfigInstance()->readConfig('date_key') . ":" . serialize($this->getDatabaseInstance()->getConnectionData()));
+               $this->extraSalt = sha1($this->fixedSalt . ":" . getenv('SERVER_SOFTWARE') . ":" . $this->getConfigInstance()->readConfig('date_key'));
 
                // Get config entry for max salt length
                $this->rndStrLen = $this->getConfigInstance()->readConfig('rnd_str_length');
@@ -131,7 +139,7 @@ class RandomNumberGenerator extends BaseFrameworkSystem {
                        $randomString .= chr($this->randomNumnber(0, 255));
                }
 
-               // Return the random string mixed up
+               // Return the random string a little mixed up
                return str_shuffle($randomString);
        }
 
@@ -143,7 +151,7 @@ class RandomNumberGenerator extends BaseFrameworkSystem {
         * @return      $num    Pseudo-random number
         */
        public function randomNumnber ($min, $max) {
-               /* @TODO I had a better random number generator here */
+               /* @TODO I had a better random number generator here but now it is somewhere lost :( */
                return mt_rand($min, $max);
        }
 
@@ -155,6 +163,15 @@ class RandomNumberGenerator extends BaseFrameworkSystem {
        public final function getExtraSalt () {
                return $this->extraSalt;
        }
+
+       /**
+        * Getter for fixed salt
+        *
+        * @return      $fixedSalt
+        */
+       public final function getFixedSalt () {
+               return $this->fixedSalt;
+       }
 }
 
 // [EOF]