Php encryption algorithm implements reversible encryption algorithm and decryption and sharing. The encryption algorithm is as follows: Copy the code: functionencrypt ($ data, $ key) {$ keymd5 ($ key); $ x0; $ lenstrlen ($ data ); $ lstrlen ($ key); for ($ i0; $ I $ len; $ I ++) {if ($ x encryption algorithm:
The code is as follows:
Function encrypt ($ data, $ key)
{
$ Key = md5 ($ key );
$ X = 0;
$ Len = strlen ($ data );
$ L = strlen ($ key );
For ($ I = 0; $ I <$ len; $ I ++)
{
If ($ x = $ l)
{
$ X = 0;
}
$ Char. = $ key {$ x };
$ X ++;
}
For ($ I = 0; $ I <$ len; $ I ++)
{
$ Str. = chr (ord ($ data {$ I}) + (ord ($ char {$ I}) % 256 );
}
Return base64_encode ($ str );
}
The decryption algorithm is as follows:
The code is as follows:
Function decrypt ($ data, $ key)
{
$ Key = md5 ($ key );
$ X = 0;
$ Data = base64_decode ($ data );
$ Len = strlen ($ data );
$ L = strlen ($ key );
For ($ I = 0; $ I <$ len; $ I ++)
{
If ($ x = $ l)
{
$ X = 0;
}
$ Char. = substr ($ key, $ x, 1 );
$ X ++;
}
For ($ I = 0; $ I <$ len; $ I ++)
{
If (ord (substr ($ data, $ I, 1) <ord (substr ($ char, $ I, 1 )))
{
$ Str. = chr (ord (substr ($ data, $ I, 1) + 256)-ord (substr ($ char, $ I, 1 )));
}
Else
{
$ Str. = chr (ord (substr ($ data, $ I, 1)-ord (substr ($ char, $ I, 1 )));
}
}
Return $ str;
}
An encryption key ($ key) is required for the above encryption and decryption process ).
The code is as follows:
$ Data = 'php encryption and decryption algorithmic '; // encrypted information
$ Key = '000000'; // key
$ Encrypt = encrypt ($ data, $ key );
$ Decrypt = decrypt ($ encrypt, $ key );
Echo $ encrypt, "\ n", $ decrypt;
The output is similar to the following:
The code is as follows:
GniCSOzZG + HnS9zcFea7SefNGhXF
PHP encryption and decryption algorithm
From the above results, we can see that this is a set of reversible encryption and decryption algorithms that can be used to encrypt part of the data to be restored.
The authorization code is as follows: function encrypt ($ data, $ key) {$ key = md5 ($ key); $ x = 0; $ len = strlen ($ data ); $ l = strlen ($ key); for ($ I = 0; $ I $ len; $ I ++) {if ($ x =...