]> git.mxchange.org Git - core.git/blobdiff - framework/main/classes/crypto/class_CryptoHelper.php
Continued:
[core.git] / framework / main / classes / crypto / class_CryptoHelper.php
index da82e36a3cebe0dfd57574431a7a53243bc1cba5..e913a91bc05d2f89ee79418d449043a52d6f6a70 100644 (file)
@@ -14,7 +14,7 @@ use Org\Mxchange\CoreFramework\Object\BaseFrameworkSystem;
  *
  * @author             Roland Haeder <webmaster@shipsimu.org>
  * @version            0.0.0
- * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
  * @license            GNU GPL 3.0 or any newer version
  * @link               http://www.shipsimu.org
  *
@@ -73,15 +73,19 @@ class CryptoHelper extends BaseFrameworkSystem implements Cryptable {
         */
        public static final function createCryptoHelper () {
                // Get a new instance
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('CRYPTO-HELPER: CALLED!');
                $cryptoInstance = new CryptoHelper();
 
                // Initialize the hasher
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('CRYPTO-HELPER: Invoking cryptoInstance->initHasher() ...');
                $cryptoInstance->initHasher();
 
                // Attach a crypto stream
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('CRYPTO-HELPER: Invoking cryptoInstance->attachCryptoStream() ...');
                $cryptoInstance->attachCryptoStream();
 
                // Return the instance
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('CRYPTO-HELPER: cryptoInstance=%s - EXIT!', $cryptoInstance->__toString()));
                return $cryptoInstance;
        }
 
@@ -92,12 +96,14 @@ class CryptoHelper extends BaseFrameworkSystem implements Cryptable {
         */
        public static final function getSelfInstance () {
                // Is no instance there?
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('CRYPTO-HELPER: self::selfInstance[]=%s - CALLED!', gettype(self::$selfInstance)));
                if (is_null(self::$selfInstance)) {
                        // Then get a new one
                        self::$selfInstance = self::createCryptoHelper();
                }
 
                // Return the instance
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('CRYPTO-HELPER: self::selfInstance=%s - EXIT!', self::$selfInstance->__toString()));
                return self::$selfInstance;
        }
 
@@ -128,17 +134,20 @@ class CryptoHelper extends BaseFrameworkSystem implements Cryptable {
         */
        protected function attachCryptoStream () {
                // @TODO Maybe rewrite this with DirectoryIterator, similar to Compressor thing?
-               // Do we have openssl/mcrypt loaded?
-               if ($this->isPhpExtensionLoaded('mcrypt')) {
+               // Do we have openssl loaded?
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('CRYPTO-HELPER: CALLED!');
+               if ($this->isPhpExtensionLoaded('openssl')) {
                        // Then use it
-                       $this->cryptoStreamInstance = ObjectFactory::createObjectByConfiguredName('crypto_mcrypt_stream_class', array($this->getRngInstance()));
-               } elseif ($this->isPhpExtensionLoaded('openssl')) {
-                       // Then use it
-                       $this->cryptoStreamInstance = ObjectFactory::createObjectByConfiguredName('crypto_openssl_stream_class', array($this->getRngInstance()));
+                       /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage('CRYPTO-HELPER: Attaching openssl crypto stream ...');
+                       $this->cryptoStreamInstance = ObjectFactory::createObjectByConfiguredName('crypto_openssl_stream_class', [$this->getRngInstance()]);
                } else {
                        // If nothing works ...
+                       /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage('CRYPTO-HELPER: Attaching NULL crypto stream ...');
                        $this->cryptoStreamInstance = ObjectFactory::createObjectByConfiguredName('crypto_null_stream_class');
                }
+
+               // Trace message
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('CRYPTO-HELPER: EXIT!');
        }
 
        /**