3 namespace Org\Mxchange\CoreFramework\Stream\Crypto\Null;
5 // Import framework stuff
6 use Org\Mxchange\CoreFramework\Generic\FrameworkInterface;
7 use Org\Mxchange\CoreFramework\Generic\UnsupportedOperationException;
8 use Org\Mxchange\CoreFramework\Stream\Crypto\BaseCryptoStream;
9 use Org\Mxchange\CoreFramework\Stream\Crypto\EncryptableStream;
12 * A null-encryption stream does not encrypt anything but can be used if e.g.
13 * openssl is not installed.
15 * @author Roland Haeder <webmaster@shipsimu.org>
17 * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 Developer Team
18 * @license GNU GPL 3.0 or any newer version
19 * @link http://www.shipsimu.org
21 * This program is free software: you can redistribute it and/or modify
22 * it under the terms of the GNU General Public License as published by
23 * the Free Software Foundation, either version 3 of the License, or
24 * (at your option) any later version.
26 * This program is distributed in the hope that it will be useful,
27 * but WITHOUT ANY WARRANTY; without even the implied warranty of
28 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
29 * GNU General Public License for more details.
31 * You should have received a copy of the GNU General Public License
32 * along with this program. If not, see <http://www.gnu.org/licenses/>.
34 class NullCryptoStream extends BaseCryptoStream implements EncryptableStream {
36 * Protected constructor
40 private function __construct () {
41 // Call parent constructor
42 parent::__construct(__CLASS__);
46 * Creates an instance of this node class
48 * @return $streamInstance An instance of this node class
50 public static final function createNullCryptoStream () {
52 $streamInstance = new NullCryptoStream();
54 // Return the instance
55 return $streamInstance;
59 * Encrypt the string with fixed salt
61 * @param $str The unencrypted string
63 * @return $encrypted Encrypted string
65 public function encryptStream (string $str, string $key = NULL) {
71 * Decrypt the string with fixed salt
73 * @param $encrypted Encrypted string
75 * @return $str The unencrypted string
77 public function decryptStream (string $encrypted, string $key = NULL) {
83 * Streams the data and maybe does something to it
85 * @param $data The data (string mostly) to "stream"
86 * @return $data The data (string mostly) to "stream"
87 * @throws UnsupportedOperationException If this method is called (which is a mistake)
89 public function streamData (string $data) {
90 self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('Unhandled ' . strlen($data) . ' bytes in this stream.');
91 throw new UnsupportedOperationException([$this, __FUNCTION__], FrameworkInterface::EXCEPTION_UNSPPORTED_OPERATION);