Jump to content

call to undefined function mcrypt_module_open()


shiza

Recommended Posts

Error: call to undefined function mcrypt_module_open()

I have copied this code form net. And i think so that mcrypt_module_open() would be a built in function. But I think it is not so. How can i define this function.

OR any other way to solve this problem??

$cipher = mcrypt_module_open(MCRYPT_RIJNDAEL_128, '', MCRYPT_MODE_CBC, '');
$iv_size = mcrypt_enc_get_iv_size($cipher);
printf("iv_size = %d\n",$iv_size);
$key256 = '12345678901234561234567890123456';
$key128 = '1234567890123456';
$iv =  '1234567890123456';

printf("iv: %s\n",bin2hex($iv));
printf("key256: %s\n",bin2hex($key256));
printf("key128: %s\n",bin2hex($key128));
$cleartext = 'The quick brown fox jumped over the lazy dog';
printf("plainText: %s\n\n",$cleartext);
if (mcrypt_generic_init($cipher, $key256, $iv) != -1)
{
	// PHP pads with NULL bytes if $cleartext is not a multiple of the block size..
	$cipherText = mcrypt_generic($cipher,$cleartext );
	mcrypt_generic_deinit($cipher);

	// Display the result in hex.
	printf("256-bit encrypted result:\n%s\n\n",bin2hex($cipherText));
}
if (mcrypt_generic_init($cipher, $key128, $iv) != -1)
{
	// PHP pads with NULL bytes if $cleartext is not a multiple of the block size..
	$cipherText = mcrypt_generic($cipher,$cleartext );
	mcrypt_generic_deinit($cipher);

	// Display the result in hex.
	printf("128-bit encrypted result:\n%s\n\n",bin2hex($cipherText));
}

Thanks In advance

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.