From: Roland Häder Date: Tue, 24 Jun 2008 21:19:29 +0000 (+0000) Subject: Garbage added to encrypted string X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=68dd5593cadad2eb87ba3e229d454049b96dce86;p=shipsimu.git Garbage added to encrypted string --- diff --git a/inc/classes/main/crypto/class_CryptoHelper.php b/inc/classes/main/crypto/class_CryptoHelper.php index 681ec64..fbe2df4 100644 --- a/inc/classes/main/crypto/class_CryptoHelper.php +++ b/inc/classes/main/crypto/class_CryptoHelper.php @@ -178,8 +178,11 @@ class CryptoHelper extends BaseFrameworkSystem implements Cryptable { $key = md5($this->rngInstance->getExtraSalt()); } + // Add some "garbage" to the string + $garbageString = md5($this->rngInstance->randomString(10))."|".base64_encode($str)."|".sha1($this->rngInstance->randomString(20)); + // Encrypt the string - $encrypted = mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $key, $str, MCRYPT_MODE_ECB, $iv); + $encrypted = mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $key, $garbageString, MCRYPT_MODE_ECB, $iv); // Return the string return $encrypted; @@ -203,8 +206,12 @@ class CryptoHelper extends BaseFrameworkSystem implements Cryptable { $key = md5($this->rngInstance->getExtraSalt()); } - // Encrypt the string - $str = mcrypt_decrypt(MCRYPT_RIJNDAEL_256, $key, $encrypted, MCRYPT_MODE_ECB, $iv); + // Decrypt the string + $garbageString = mcrypt_decrypt(MCRYPT_RIJNDAEL_256, $key, $encrypted, MCRYPT_MODE_ECB, $iv); + + // Get the real string out + $strArray = explode("|", $garbageString); + $str = base64_decode($strArray[1]); // Trim trailing nulls away $str = rtrim($str, "\0"); diff --git a/inc/classes/main/helper/captcha/images/class_ImageHelper.php b/inc/classes/main/helper/captcha/images/class_ImageHelper.php index 48ad6f0..8d59e70 100644 --- a/inc/classes/main/helper/captcha/images/class_ImageHelper.php +++ b/inc/classes/main/helper/captcha/images/class_ImageHelper.php @@ -328,7 +328,7 @@ class ImageHelper extends BaseCaptcha implements HelpableTemplate { public final function setFontSize ($fontSize) { // Random font size? if ($fontSize === "rand") { - $fontSize = $this->getRngInstance()->randomNumber(3, 9); + $fontSize = $this->getRngInstance()->randomNumber(4, 9); } // END - if $this->imageStrings[$this->currString]['size'] = (int) $fontSize;