Search code examples
php3des

Using mcrypt_encrypt() give me warning "Size of key is too long"


I'm trying to use mcrypt_encrypt() in PHP but I've a problem when I use the function to encrypt:

My code is:

Vars:

$key = "1e1r1r1t1y1y1g1g1g1g1g1345678910"; // That is a example, the real key have 32 long too.
$ref="12013515"; // example value

// Tamanio Encripyt ....
$iv_size = mcrypt_get_iv_size(MCRYPT_3DES,MCRYPT_MODE_CBC);
$iv = mcrypt_create_iv($iv_size,MCRYPT_RAND);
// Lunch
$stringEncrypted = mcrypt_encrypt(MCRYPT_3DES,$key,$ref,MCRYPT_MODE_CBC,$iv);

If I do that, PHP show me the error:

Warning: mcrypt_encrypt(): Size of key is too large for this algorithm

I need to use the encrypt 3DES...what can be the problem?


Solution

  • Key of size 32 not supported by this algorithm. Only keys of size 24 supported.