Php implements the rc4 encryption algorithm. Php implements the rc4 encryption algorithm. the decryption method of this algorithm is to re-encrypt it to restore the content referenced by CopytoClipboard: [www.veryhuo.com] ** rc4 encryption algorithm ** $ pwd Key * php implements the rc4 encryption algorithm. the decryption method of this algorithm is to re-encrypt it and then restore it.
Copy to ClipboardReference: [www.bkjia.com]/*
* Rc4 encryption algorithm
* $ Pwd key
* $ Data the data to be encrypted
*/
Function rc4 ($ pwd, $ data) // $ pwd key $ data requires an encrypted string
{
$ Key [] = "";
$ Box [] = "";
$ Pwd_length = strlen ($ pwd );
$ Data_length = strlen ($ data );
For ($ I = 0; I I <256; $ I ++)
{
$ Key [$ I] = ord ($ pwd [$ I % $ pwd_length]);
$ Box [$ I] = $ I;
}
For ($ j = $ I = 0; I I <256; $ I ++)
{
$ J = ($ j + $ box [$ I] + $ key [$ I]) % 256;
$ Tmp = $ box [$ I];
$ Box [$ I] = $ box [$ j];
$ Box [$ j] = $ tmp;
}
For ($ a = $ j = $ I = 0; $ I <$ data_length; $ I ++)
{
$ A = ($ a + 1) % 256;
$ J = ($ j + $ box [$ a]) % 256;
$ Tmp = $ box [$ a];
$ Box [$ a] = $ box [$ j];
$ Box [$ j] = $ tmp;
$ K = $ box [($ box [$ a] + $ box [$ j]) % 256)];
$ Cipher. = chr (ord ($ data [$ I]) ^ $ k );
}
Return $ cipher;
}
[Www.veryhuo.com]/** rc4 encryption algorithm * $ pwd Key *...