* 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 encryptStream ($str) {
+ public function encryptStream ($str, $key = null) {
// Init crypto module
$iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB);
$iv = mcrypt_create_iv($iv_size, MCRYPT_RAND);
- // Generate key
- $key = $this->getRngInstance()->generateKey();
+ // Generate key, if none provided
+ if (is_null($key)) {
+ // None provided
+ $key = $this->getRngInstance()->generateKey();
+ } // END - if
// Add some "garbage" to the string
switch ($this->getRngInstance()->randomNumber(0, 8)) {