Merge branch 'master' into php5

* master:
  RC4: speedups
This commit is contained in:
Andreas Fischer 2014-06-16 16:28:29 +02:00
commit 635c524b6b

View File

@ -267,10 +267,7 @@ class Crypt_RC4 extends Crypt_Base
{
$key = $this->key;
$keyLength = strlen($key);
$keyStream = array();
for ($i = 0; $i < 256; $i++) {
$keyStream[$i] = $i;
}
$keyStream = range(0, 255);
$j = 0;
for ($i = 0; $i < 256; $i++) {
$j = ($j + $keyStream[$i] + ord($key[$i % $keyLength])) & 255;
@ -324,7 +321,7 @@ class Crypt_RC4 extends Crypt_Base
$keyStream[$i] = $ksj;
$keyStream[$j] = $ksi;
$text[$k] = chr(ord($text[$k]) ^ $keyStream[($ksj + $ksi) & 255]);
$text[$k] = $text[$k] ^ chr($keyStream[($ksj + $ksi) & 255]);
}
return $text;