diff --git a/cake/libs/security.php b/cake/libs/security.php index e9d5c7f9439..fe65c7e8130 100644 --- a/cake/libs/security.php +++ b/cake/libs/security.php @@ -177,12 +177,14 @@ function cipher($text, $key) { srand(Configure::read('Security.cipherSeed')); $out = ''; - for ($i = 0; $i < strlen($text); $i++) { - for ($j = 0; $j < ord(substr($key, $i % strlen($key), 1)); $j++) { - $toss = rand(0, 255); + $keyLength = strlen($key); + for ($i = 0, $j = strlen($text); $i < $j; $i++) { + $k = ord($key[$i % $keyLength]); + while ($k-- > 0) { + rand(0, 255); } $mask = rand(0, 255); - $out .= chr(ord(substr($text, $i, 1)) ^ $mask); + $out .= chr(ord($text[$i]) ^ $mask); } srand();