Jump to content

Problem with mcrypt function in PHP 5.2.9


Recommended Posts

I'm having some problem on using 3DES encryption in PHP 5.2.9.

I have followed all the steps to configure mcrypt in php.ini file.I have removed the ; from the extensions extension=php_mcrypt.dll and i also made a copy/paste of libmcrypt.dll from the folder php to C:/WINDOWS/system32/.I have restarted the Webserver Apache but when i tried to encrypt data using encrypt and decrypt function created in php code i'm having the error message below:Call to undefined function mcrypt_module_open() .

 

Could you kindly help me to resolve this problem?

 

Below you will find the code that i used :

 

</html>

<head><title>Encryption</title>

</head>

<body>

 

<form name=form method=post action='encrypt.php'>

<table align=center>

<TR><TD>Source Text:</TD><TD><input type=text name=input value=<?php echo $_REQUEST['input']; ?>></TD></TR>

<TR><TD>Key:</TD><TD><input type=text name=key value=<?php echo $_REQUEST['key']; ?>></TD></TR>

</table>

<input type=submit>

</form>

<?php

if(!empty($_REQUEST['input'])){

  $encrypted=encrypt($_REQUEST['input']);

  $decrypted=decrypt($encrypted);

 

  echo "Encrypted : '$encrypted' Decrypted: '$decrypted' <BR>";

}

 

$key = $_REQUEST['key'];

 

//Encrypt Function

function encrypt($encrypt) {

  global $key;

  $iv = mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB), MCRYPT_RAND);

  $passcrypt = mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $key, $encrypt, MCRYPT_MODE_ECB, $iv);

  $encode = base64_encode($passcrypt);

return $encode;

}

 

//Decrypt Function

function decrypt($decrypt) {

  global $key;

  $decoded = base64_decode($decrypt);

  $iv = mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB), MCRYPT_RAND);

  $decrypted = mcrypt_decrypt(MCRYPT_RIJNDAEL_256, $key, $decoded, MCRYPT_MODE_ECB, $iv);

return $decrypted;

}

 

?>

 

</body>

</html>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.