]> git.mxchange.org Git - shipsimu.git/commitdiff
Garbage added to encrypted string
authorRoland Häder <roland@mxchange.org>
Tue, 24 Jun 2008 21:19:29 +0000 (21:19 +0000)
committerRoland Häder <roland@mxchange.org>
Tue, 24 Jun 2008 21:19:29 +0000 (21:19 +0000)
inc/classes/main/crypto/class_CryptoHelper.php
inc/classes/main/helper/captcha/images/class_ImageHelper.php

index 681ec646b8e44210d6e482c6ba253a08c401bb99..fbe2df4e14c175248dd6cc46b6156fac948d4d52 100644 (file)
@@ -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");
index 48ad6f0c480f13b49fb3949eaf318305681bfd17..8d59e709b8ecd41401ea0fbc3cbab44e544d5693 100644 (file)
@@ -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;