* A standard random number generator
*
* @author Roland Haeder <webmaster@ship-simu.org>
- * @version 0.3.0
+ * @version 0.0.0
* @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software
* @license GNU GPL 3.0 or any newer version
- * @link http://www.mxchange.org
+ * @link http://www.ship-simu.org
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
*/
private $extraSalt = "";
+ /**
+ * Fixed salt for secured hashing
+ */
+ private $fixedSalt = "";
+
/**
* Maximum length for random string
*/
private $rndStrLen = 0;
/**
- * Private constructor
+ * Protected constructor
*
* @param $className Name of this class
* @return void
$this->setObjectDescription("Standard random number generator");
// Create unique ID number
- $this->createUniqueID();
+ $this->generateUniqueId();
// Clean up a little
$this->removeNumberFormaters();
// Set the server IP to cluster
$serverIp = "cluster";
+
// Do we have a single server?
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 for stronger salt!
- $this->extraSalt = sha1($serverIp . ":" . getenv('SERVER_SOFTWARE') . ":" . $this->getConfigInstance()->readConfig('date_key') . ":" . serialize($this->getDatabaseInstance()->getConnectionData()));
+ /* @TODO Add site key for stronger salt! */
+ $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');
$randomString .= chr($this->randomNumnber(0, 255));
}
- // Return the random string mixed up
+ // Return the random string a little mixed up
return str_shuffle($randomString);
}
* @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);
}
public final function getExtraSalt () {
return $this->extraSalt;
}
+
+ /**
+ * Getter for fixed salt
+ *
+ * @return $fixedSalt
+ */
+ public final function getFixedSalt () {
+ return $this->fixedSalt;
+ }
}
// [EOF]