The 'key' for encryption can now be taken from fixed or daily-changed extra salt
[shipsimu.git] / inc / classes / main / crypto / class_CryptoHelper.php
index 2765abddbbb163014a22046bdc09d0c8d9ddf323..aab378491f31119b6166e52ca99a700bb0f3ee82 100644 (file)
@@ -168,7 +168,11 @@ class CryptoHelper extends BaseFrameworkSystem implements Cryptable {
                $iv = mcrypt_create_iv($iv_size, MCRYPT_RAND);
 
                // Get key
-               $key = md5($this->rngInstance->getFixedSalt());
+               if ($this->getConfigInstance()->readConfig('crypt_fixed_salt') == "Y") {
+                       $key = md5($this->rngInstance->getFixedSalt());
+               } else {
+                       $key = md5($this->rngInstance->getExtraSalt());
+               }
 
                // Encrypt the string
                $encrypted = mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $key, $str, MCRYPT_MODE_ECB, $iv);
@@ -189,7 +193,11 @@ class CryptoHelper extends BaseFrameworkSystem implements Cryptable {
                $iv = mcrypt_create_iv($iv_size, MCRYPT_RAND);
 
                // Get key
-               $key = md5($this->rngInstance->getFixedSalt());
+               if ($this->getConfigInstance()->readConfig('crypt_fixed_salt') == "Y") {
+                       $key = md5($this->rngInstance->getFixedSalt());
+               } else {
+                       $key = md5($this->rngInstance->getExtraSalt());
+               }
 
                // Encrypt the string
                $str = mcrypt_decrypt(MCRYPT_RIJNDAEL_256, $key, $encrypted, MCRYPT_MODE_ECB, $iv);