<?php
$plaintext = "Four score and seven years ago";
$cipher = MCRYPT_TRIPLEDES;
$mode = MCRYPT_MODE_ECB;
$rand_src = MCRYPT_DEV_RANDOM;
$password = 'Extra secret password';
print ("Plaintext: $plaintext\n");
// Ok, let's encrypt the data
$handle = mcrypt_module_open ($cipher, ' ' , $mode, ' ');
if ($handle)
die ("Couldn't locate open mcrypt module for '$cipher', algorithm");
$iv_size = mcrypt_enc_get_iv_size ($handle);
$ivector = mcrypt_create_iv ($iv_size, $rand_src);
if (mcrypt_generic_init ($handle, $password, $ivector) == -1)
die ("Error: mcrypt_generic_int() failed.");
$ciphertext = mcrypt_generic ($handle, $plaintext);
mcrypt_generic_end ($handle);
print ("Ciphertext: " . bin2hex ($ciphertext) . "\n");
// Now let's decrypt it
$handle = mcrypt_module_open ($cipher, ' ', $mode, ' ');
if (!$handle)
die ("Couldn't locate open mcrypt module for '$cipher' algorithm");
if (mcrypt_generic_init ($handle, $password, $ivector) == -1)
die ("Error: mcrypt_generic_init() failed also.");
$plaintext = mdecrypt_generic ($handle, $ciphertext);
mcrypt_generic_end ($handle);
print ("Plaintext: $plaintext\n");
?>
This is the code using mcrypt but when i try at the server.It appear error like this Notice: Use of undefined constant MCRYPT_TRIPLEDES - assumed 'MCRYPT_TRIPLEDES' in C:\Program Files\Apache Group\Apache2\htdocs\encrypt.php on line 4
Notice: Use of undefined constant MCRYPT_MODE_ECB - assumed 'MCRYPT_MODE_ECB' in C:\Program Files\Apache Group\Apache2\htdocs\encrypt.php on line 5
Notice: Use of undefined constant MCRYPT_DEV_RANDOM - assumed 'MCRYPT_DEV_RANDOM' in C:\Program Files\Apache Group\Apache2\htdocs\encrypt.php on line 6
Plaintext: Four score and seven years ago
Fatal error: Call to undefined function: mcrypt_module_open() in C:\Program Files\Apache Group\Apache2\htdocs\encrypt.php on line 12
Please help me!!!!!