]> git.mxchange.org Git - core.git/blobdiff - framework/main/classes/utils/crypto/class_CryptoUtils.php
Continued:
[core.git] / framework / main / classes / utils / crypto / class_CryptoUtils.php
index 3677b4e40993faedfd22cc254b05bec1250b34d8..99254d13ce7d11644585fc79c1e1c2bceb307eef 100644 (file)
@@ -54,22 +54,24 @@ final class CryptoUtils extends BaseFrameworkSystem {
         * @param       $str    The string to be hashed
         * @return      $hash   The hash from string $str
         * @throws      InvalidArgumentException        If a parameter is not valid
-        * @throws      LogicException  If proper extension ext-mhash is not loaded
+        * @throws      LogicException  If proper extension hash is not loaded
         */
        public static final function hash (string $str) {
                // Validate parameter/mhash extension
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('CRYPTO-UTILS: str=%s - CALLED!', $str));
                if (empty($str)) {
                        // Throw IAE
                        throw new InvalidArgumentException('Parameter "str" is empty');
-               } elseif (!extension_loaded('mhash')) {
+               } elseif (!extension_loaded('hash')) {
                        // Should be there
-                       throw new LogicException('Extension ext-mhash not loaded');
+                       throw new LogicException('Extension ext-hash not loaded');
                }
 
                // Hash given string with (better secure) hasher
-               $hash = bin2hex(mhash(MHASH_SHA256, $str));
+               $hash = hash('sha256', $str, true);
 
                // Return it
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('CRYPTO-UTILS: hash(%d){}=%s - EXIT!', strlen($hash), bin2hex($hash)));
                return $hash;
        }