]> git.mxchange.org Git - core.git/blobdiff - inc/classes/main/crypto/class_CryptoHelper.php
Added parameter 'key' to encryption methods to allow own keys
[core.git] / inc / classes / main / crypto / class_CryptoHelper.php
index c135b18971cdf4bb0f75d154d24d5c212765b678..5e40560622673b8b4d4e6d83a300eb14e7f3eb86 100644 (file)
@@ -4,7 +4,7 @@
  *
  * @author             Roland Haeder <webmaster@ship-simu.org>
  * @version            0.0.0
- * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 Core Developer Team
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2011 Core Developer Team
  * @license            GNU GPL 3.0 or any newer version
  * @link               http://www.ship-simu.org
  *
@@ -54,10 +54,6 @@ class CryptoHelper extends BaseFrameworkSystem implements Cryptable {
        protected function __construct () {
                // Call parent constructor
                parent::__construct(__CLASS__);
-
-               // Clean up a little
-               $this->removeNumberFormaters();
-               $this->removeSystemArray();
        }
 
        /**
@@ -65,7 +61,7 @@ class CryptoHelper extends BaseFrameworkSystem implements Cryptable {
         *
         * @return      $cryptoInstance         An instance of this crypto helper class
         */
-       public final static function createCryptoHelper () {
+       public static final function createCryptoHelper () {
                // Get a new instance
                $cryptoInstance = new CryptoHelper();
 
@@ -84,7 +80,7 @@ class CryptoHelper extends BaseFrameworkSystem implements Cryptable {
         *
         * @return      $selfInstance   An instance of this crypto helper class
         */
-       public final static function getInstance () {
+       public static final function getInstance () {
                // Is no instance there?
                if (is_null(self::$selfInstance)) {
                        // Then get a new one
@@ -183,11 +179,12 @@ class CryptoHelper extends BaseFrameworkSystem implements Cryptable {
         * Encrypt the string with fixed salt
         *
         * @param       $str            The unencrypted string
+        * @param       $key            Optional key, if none provided, a random key will be generated
         * @return      $encrypted      Encrypted string
         */
-       public function encryptString ($str) {
+       public function encryptString ($str, $key = null) {
                // Encrypt the string through the stream
-               $encryted = $this->cryptoStreamInstance->encryptStream($str);
+               $encrypted = $this->cryptoStreamInstance->encryptStream($str, $key);
 
                // Return the string
                return $encrypted;