note 43872 deleted from function.mcrypt-encrypt by cece

From: Date: Wed, 03 Nov 2004 02:20:33 +0000
Subject: note 43872 deleted from function.mcrypt-encrypt by cece
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-79529@lists.php.net to get a copy of this message
Note Submitter: andrewcare at execulink dot com ---- Plaintext encryption: <? $data = "Plaintext"; // Data to encrypt (http://www.ciphersbyritter.com/glossary.htm#Encryption) $key = "Secret"; // Encryption key (http://www.ciphersbyritter.com/glossary.htm#Key) $td = MCRYPT_RIJNDAEL_256; // Encryption cipher (http://www.ciphersbyritter.com/glossary.htm#Cipher) $iv_size = mcrypt_get_iv_size($td, MCRYPT_MODE_ECB); // Dependant on cipher/mode combination (http://www.php.net/manual/en/function.mcrypt-get-iv-size.php) $iv = mcrypt_create_iv($iv_size, MCRYPT_RAND); // Creates an IV (http://www.ciphersbyritter.com/glossary.htm#IV) echo "Original data: $data<br />"; $encrypted_data = mcrypt_encrypt($td, $key, $data, MCRYPT_MODE_CBC, $iv); // Encrypts data (http://www.php.net/manual/en/function.mcrypt-encrypt.php) echo "Encrypted data: " . bin2hex($encrypted_data) /* bin2hex to compensate for random character values */ . "<br />"; $data = mcrypt_decrypt($td, $key, $encrypted_data, MCRYPT_MODE_CBC, $iv); // Decrypts data (http://www.php.net/manual/en/function.mcrypt-decrypt.php) echo "Decrypted data: $data<br />"; ?>

« previous php.notes (#79529) next »