]> 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 7ef8d3f3adab43aab9ab033cf5e0a86f2ef3fd35..0455b2a1882cf6d9d62fd699cfa4f44cc5512bdf 100644 (file)
@@ -6,7 +6,7 @@ namespace Org\Mxchange\CoreFramework\Helper\Crypto;
 use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap;
 use Org\Mxchange\CoreFramework\Crypto\Cryptable;
 use Org\Mxchange\CoreFramework\Crypto\RandomNumber\RandomNumberGenerator;
-use Org\Mxchange\CoreFramework\Factory\ObjectFactory;
+use Org\Mxchange\CoreFramework\Factory\Object\ObjectFactory;
 use Org\Mxchange\CoreFramework\Object\BaseFrameworkSystem;
 
 /**
@@ -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 - 2020 Core Developer Team
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2021 Core Developer Team
  * @license            GNU GPL 3.0 or any newer version
  * @link               http://www.shipsimu.org
  *
@@ -61,7 +61,7 @@ class CryptoHelper extends BaseFrameworkSystem implements Cryptable {
         *
         * @return      void
         */
-       protected function __construct () {
+       private function __construct () {
                // Call parent constructor
                parent::__construct(__CLASS__);
        }
@@ -95,7 +95,7 @@ class CryptoHelper extends BaseFrameworkSystem implements Cryptable {
                if (is_null(self::$selfInstance)) {
                        // Then get a new one
                        self::$selfInstance = self::createCryptoHelper();
-               } // END - if
+               }
 
                // Return the instance
                return self::$selfInstance;
@@ -184,7 +184,7 @@ class CryptoHelper extends BaseFrameworkSystem implements Cryptable {
                if (FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('extension_uuid_loaded') === true) {
                        // Then add it as well
                        $uuid = uuid_create();
-               } // END - if
+               }
 
                // Return it
                return $uuid;
@@ -201,10 +201,7 @@ class CryptoHelper extends BaseFrameworkSystem implements Cryptable {
         * @param       $withFixed      Whether to include a fixed salt (not recommended in p2p applications)
         * @return      $hashed         The hashed and salted string
         */
-       public function hashString ($str, $oldHash = '', $withFixed = true) {
-               // Cast the string
-               $str = (string) $str;
-
+       public function hashString (string $str, string $oldHash = '', bool $withFixed = true) {
                // Default is the default salt ;-)
                $salt = $this->salt;
 
@@ -215,7 +212,7 @@ class CryptoHelper extends BaseFrameworkSystem implements Cryptable {
 
                        // 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";
@@ -245,7 +242,7 @@ class CryptoHelper extends BaseFrameworkSystem implements Cryptable {
         * @param       $key            Optional key, if none provided, a random key will be generated
         * @return      $encrypted      Encrypted string
         */
-       public function encryptString ($str, $key = NULL) {
+       public function encryptString (string $str, string $key = NULL) {
                // Encrypt the string through the stream
                $encrypted = $this->cryptoStreamInstance->encryptStream($str, $key);
 
@@ -259,7 +256,7 @@ class CryptoHelper extends BaseFrameworkSystem implements Cryptable {
         * @param       $encrypted      Encrypted string
         * @return      $str            The unencrypted string
         */
-       public function decryptString ($encrypted) {
+       public function decryptString (string $encrypted) {
                // Encrypt the string through the stream
                $str = $this->cryptoStreamInstance->decryptStream($encrypted);