PHP Code:--------------------------------------------------------------------------------
function Make_seed () {
List ($usec, $sec) = explode (' ', Microtime ());
return (float) $sec + ((float) $usec * 100000);
}
Srand (Make_seed ());
/* Turn on encryption algorithm/*/
$TD = Mcrypt_module_open (' Twofish ', ', ' ECB ', ');
/* Build IV and check the length of key */
$iv = Mcrypt_create_iv (Mcrypt_enc_get_iv_size ($TD), Mcrypt_rand);
$ks = Mcrypt_enc_get_key_size ($TD);
/* Generate key */
$key = substr (MD5 (' very secret key '), 0, $ks);
/* Initialize the encryption program */
Mcrypt_generic_init ($TD, $key, $IV);
/* Encrypted, $encrypted saved with encrypted data */
Print $encrypted = Mcrypt_generic ($TD, ' This is very important data ');
/* Detect Cryptographic Handles */
Mcrypt_generic_deinit ($TD);
/* Initialize the cryptographic module to decrypt */
Mcrypt_generic_init ($TD, $key, $IV);
/* Decrypt */
$decrypted = Mdecrypt_generic ($TD, $encrypted);
/* Detect the decryption handle and close the module */
Mcrypt_generic_deinit ($TD);
Mcrypt_module_close ($TD);
/* Show Original String */
echo Trim ($decrypted). "";
http://www.bkjia.com/PHPjc/629310.html www.bkjia.com true http://www.bkjia.com/PHPjc/629310.html techarticle PHP Code:--------------------------------------------------------------------------------function Make_seed () { List ($usec, $sec) = explode (' ', Microtime ()); return (float) $sec + ...