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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.