PHP code :--------------------------------------------------------------------------------
Function make_seed (){
List ($ usec, $ sec) = explode ('', microtime ());
Return (float) $ sec + (float) $ usec * 100000 );
}
Srand (make_seed ());
/* Enable the encryption algorithm /*/
$ Td = mcrypt_module_open ('twofish ',', 'ecb ',');
/* Create an IV and check the key length */
$ Iv = mcrypt_create_iv (mcrypt_enc_get_iv_size ($ td), MCRYPT_RAND );
$ Ks = mcrypt_enc_get_key_size ($ td );
/* Generate the key */
$ Key = substr (md5 ('very secret key'), 0, $ ks );
/* Initialize the encryption program */
Mcrypt_generic_init ($ td, $ key, $ iv );
/* Encrypted, $ encrypted stores encrypted data */
Print $ encrypted = mcrypt_generic ($ td, 'this is very important data ');
/* Check the encryption handle */
Mcrypt_generic_deinit ($ td );
/* Initialize the encryption module for decryption */
Mcrypt_generic_init ($ td, $ key, $ iv );
/* Decrypt */
$ Decrypted = mdecrypt_generic ($ td, $ encrypted );
/* Check the decryption handle and close the module */
Mcrypt_generic_deinit ($ td );
Mcrypt_module_close ($ td );
/* Display the original string */
Echo trim ($ decrypted )."";