des is a standard data encryption algorithm, the detailed introduction of this algorithm can refer to the wiki and Baidu Encyclopedia:
Wiki Encyclopedia Baidu Encyclopedia
PHP has an extension to support DES encryption algorithm, is: Extension=php_mcrypt.dll
Opening this extension in a configuration file is not yet available in the Windows environment
It is necessary to copy the Libmcrypt.dll under the PHP folder to the System32 directory of the system, which can be viewed by phpinfo mcrypt means that the module can be tested properly.
Here is an example of using DES encryption to decrypt PHP:
Copy the Code code as follows:
$input-stuff to decrypt
$key-the secret key to use
function Do_mencrypt ($input, $key)
{
$input = Str_replace ("" N "," ", $input);
$input = Str_replace ("" T "," ", $input);
$input = Str_replace ("R", "", $input);
$key = substr (MD5 ($key), 0, 24);
$TD = Mcrypt_module_open (' TripleDES ', ' ', ' ECB ', ');
$iv = Mcrypt_create_iv (Mcrypt_enc_get_iv_size ($TD), Mcrypt_rand);
Mcrypt_generic_init ($TD, $key, $IV);
$encrypted _data = Mcrypt_generic ($TD, $input);
Mcrypt_generic_deinit ($TD);
Mcrypt_module_close ($TD);
Return Trim (Chop (Base64_encode ($encrypted _data));
}
$input-stuff to decrypt
$key-the secret key to use
function Do_mdecrypt ($input, $key)
{
$input = Str_replace ("" N "," ", $input);
$input = Str_replace ("" T "," ", $input);
$input = Str_replace ("R", "", $input);
$input = Trim (Chop (Base64_decode ($input)));
$TD = Mcrypt_module_open (' TripleDES ', ' ', ' ECB ', ');
$key = substr (MD5 ($key), 0, 24);
$iv = Mcrypt_create_iv (Mcrypt_enc_get_iv_size ($TD), Mcrypt_rand);
Mcrypt_generic_init ($TD, $key, $IV);
$decrypted _data = Mdecrypt_generic ($TD, $input);
Mcrypt_generic_deinit ($TD);
Mcrypt_module_close ($TD);
Return Trim (Chop ($decrypted _data));
}
http://www.bkjia.com/PHPjc/327421.html www.bkjia.com true http://www.bkjia.com/PHPjc/327421.html techarticle des is a standard data encryption algorithm, the detailed introduction of this algorithm can refer to the wiki and Baidu encyclopedia: wiki wikipedia Baidu encyclopedia php has an extension can support des encryption calculation ...