]> git.mxchange.org Git - shipsimu.git/blobdiff - inc/classes/main/crypto/class_CryptoHelper.php
Assertion added to crypto helper (CAPTCHA might still be broken, why?)
[shipsimu.git] / inc / classes / main / crypto / class_CryptoHelper.php
index 0968b5271353c83b591f02c1d4fd01790ccc80b0..1ccdaae901b0712c8644e6001b8de53598cd050d 100644 (file)
@@ -19,7 +19,7 @@
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
  */
 class CryptoHelper extends BaseFrameworkSystem implements Cryptable {
        // Exception constants
@@ -50,12 +50,6 @@ class CryptoHelper extends BaseFrameworkSystem implements Cryptable {
                // Call parent constructor
                parent::__construct(__CLASS__);
 
-               // Set part description
-               $this->setObjectDescription("Cryptographical helper");
-
-               // Create unique ID number
-               $this->generateUniqueId();
-
                // Clean up a little
                $this->removeNumberFormaters();
                $this->removeSystemArray();
@@ -136,17 +130,17 @@ class CryptoHelper extends BaseFrameworkSystem implements Cryptable {
                // Cast the string
                $str = (string) $str;
 
+               // Default is the default salt ;-)
+               $salt = $this->salt;
+
                // Is the old password set?
-               if (empty($oldHash)) {
-                       // No, then use the current salt
-                       $salt = $this->salt;
-               } else {
+               if (!empty($oldHash)) {
                        // Use the salt from hash, first get length
                        $length = $this->getConfigInstance()->readConfig('salt_length');
 
                        // Then extract the X first characters from the hash as our salt
                        $salt = substr($oldHash, 0, $length);
-               }
+               } // END - if
 
                // Hash the password with salt
                //* DEBUG: */ echo "salt=".$salt."/plain=".$str."<br />\n";
@@ -247,6 +241,11 @@ class CryptoHelper extends BaseFrameworkSystem implements Cryptable {
 
                // Get the real string out
                $strArray = explode("|", $garbageString);
+
+               // Does the element count match?
+               assert(count($strArray) == 3);
+
+               // Decode the string
                $str = base64_decode($strArray[1]);
 
                // Trim trailing nulls away