diff --git a/phpseclib/Crypt/RC4.php b/phpseclib/Crypt/RC4.php index 14bf67e4..b709590a 100644 --- a/phpseclib/Crypt/RC4.php +++ b/phpseclib/Crypt/RC4.php @@ -212,6 +212,8 @@ class Crypt_RC4 { $this->key = $key; if ( CRYPT_RC4_MODE == CRYPT_RC4_MODE_MCRYPT ) { + mcrypt_generic_init($this->encryptStream, $this->key, ''); + mcrypt_generic_init($this->decryptStream, $this->key, ''); return; } @@ -352,10 +354,10 @@ class Crypt_RC4 { if ( CRYPT_RC4_MODE == CRYPT_RC4_MODE_MCRYPT ) { $keyStream = $mode == CRYPT_RC4_ENCRYPT ? 'encryptStream' : 'decryptStream'; - if ($this->continuousBuffer) { - return mcrypt_generic($this->$keyStream, $text); + if (!$this->continuousBuffer) { + mcrypt_generic_init($this->$keyStream, $this->key, ''); } - mcrypt_generic_init($this->$keyStream, $this->key, ''); + return mcrypt_generic($this->$keyStream, $text); } @@ -515,4 +517,4 @@ class Crypt_RC4 { } // vim: ts=4:sw=4:et: -// vim6: fdl=1: +// vim6: fdl=1: \ No newline at end of file