X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=inc%2Fclasses%2Fmain%2Fcrypto%2Fclass_CryptoHelper.php;h=61df314948539b8df5a9d01658b16b14b409ab46;hb=d90e5850767bfef7a3307df1bca5cbaee21cbe64;hp=db35284416ecb4011caa28f565c43f455dfcc56d;hpb=2c0148a84570f1a8343fa6b98a279e903b3e4fa2;p=core.git diff --git a/inc/classes/main/crypto/class_CryptoHelper.php b/inc/classes/main/crypto/class_CryptoHelper.php index db352844..61df3149 100644 --- a/inc/classes/main/crypto/class_CryptoHelper.php +++ b/inc/classes/main/crypto/class_CryptoHelper.php @@ -4,7 +4,7 @@ * * @author Roland Haeder * @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 * @@ -29,17 +29,12 @@ class CryptoHelper extends BaseFrameworkSystem implements Cryptable { /** * An instance of this own clas */ - private static $selfInstance = null; - - /** - * Instance of the random number generator - */ - private $rngInstance = null; + private static $selfInstance = NULL; /** * Instance of the crypto stream */ - private $cryptoStreamInstance = null; + private $cryptoStreamInstance = NULL; /** * Salt for hashing operations @@ -61,7 +56,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(); @@ -80,7 +75,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 getSelfInstance () { // Is no instance there? if (is_null(self::$selfInstance)) { // Then get a new one @@ -179,11 +174,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 - $encrypted = $this->cryptoStreamInstance->encryptStream($str); + $encrypted = $this->cryptoStreamInstance->encryptStream($str, $key); // Return the string return $encrypted;