MIOLO20
Carregando...
Procurando...
Nenhuma entrada encontrada
mrc4crypt.class
Ir para a documentação deste ficheiro.
1
<?php
2
3
// Adapted from Javascript code at http://shop-js.sourceforge.net
4
// Created On: June 20, 2003
5
10
class
MRC4Crypt
11
{
22
function
rc4
($key, $text)
23
{
24
$s = array
25
(
26
);
27
28
for
($i = 0; $i < 256; $i++)
29
{
30
$s[$i] = $i;
31
}
32
33
$key_length = strlen($key);
34
$y = 0;
35
36
for
($x = 0; $x < 256; $x++)
37
{
38
$c = ord(substr($key, ($x % $key_length), 1));
39
$y = ($c + $s[$x] + $y) % 256;
40
$temp_swap = $s[$x];
41
$s[$x] = $s[$y];
42
$s[$y] = $temp_swap;
43
}
44
45
$cipher =
""
;
46
$x = 0;
47
$y = 0;
48
$z =
""
;
49
50
for
($x = 0; $x < strlen($text); $x++)
51
{
52
$x2 = $x % 256;
53
$y = ($s[$x2] + $y) % 256;
54
$temp = $s[$x2];
55
$s[$x2] = $s[$y];
56
$s[$y] = $temp;
57
$z = $s[(($s[$x2] + $s[$y]) % 256)];
58
$cipherby = ord(substr($text, $x, 1)) ^ $z;
59
$cipher .= chr($cipherby);
60
}
61
62
return
$cipher;
63
}
64
}
65
?>
MRC4Crypt
Definição
mrc4crypt.class:11
MRC4Crypt\rc4
rc4($key, $text)
Definição
mrc4crypt.class:22
classes
security
mrc4crypt.class
Gerado por
1.10.0