Php implements the rc4 encryption algorithm code. Copy the code as follows: ** rc4 encryption algorithm * $ pwd Key * $ data the data to be encrypted * functionrc4 ($ pwd, $ data) $ pwd key $ data requires an encrypted string {$ key []; $ box [code
The code is as follows:
/*
* 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;
}
The authorization code is as follows:/** rc4 encryption algorithm * $ pwd Key * $ data the data to be encrypted */function rc4 ($ pwd, $ data) // $ pwd key $ data requires an encrypted string {$ key [] = ""; $ box [...