mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-19 02:56:15 +00:00
Optimized Security::cipher(). Fixes #176
Signed-off-by: Mark Story <mark@mark-story.com>
This commit is contained in:
parent
1cfd273052
commit
ad496cea18
1 changed files with 6 additions and 4 deletions
|
@ -177,12 +177,14 @@ class Security extends Object {
|
|||
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();
|
||||
|
|
Loading…
Add table
Reference in a new issue