We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Phalcon\Crypt() Question

Hello,

I'm using ( studying =) ) Phalcon 1.1.0 and according documentation https://media.readthedocs.org/pdf/phalcon-php-framework-documentation/latest/phalcon-php-framework-documentation.pdf Tried to test Encryption functionality and used following code:

$crypt = new \Phalcon\Crypt(); $key = 'le password'; $text = 'This is a secret text'; echo $encrypted = $crypt->encrypt($text,$key); echo $crypt->decrypt($encrypted,$key);

Unfortunatelly it fails with error: Warning: mcrypt_decrypt(): The IV parameter must be as long as the blocksize in \test.php on line 59

Can you tell me in what my mistake or show a working code example.

P.S. I've also tryied following code:

$crypt = new \Phalcon\Crypt();

$crypt->setKey('le password') ->setCipher('cast-256') ->setMode('ofb'); $text = 'This is a secret text'; echo $encrypted = $crypt->encrypt($text); echo $crypt->decrypt($encrypted);

Usually it throw an error: Warning: mcrypt_decrypt(): The IV parameter must be as long as the blocksize in D:\Internet\ext.dev\www\zz-consulting\test.php on line 62

though sometimes success, maybe in 10% of all calls

Thank you.



98.9k

Hi, could you check using the latest DLL? (uploaded today)



5.4k

Hello!

Unforytnatelly no changes. Used:

x86 Phalcon 1.1.0 - Windows x86 for PHP 5.4.0 (VC9) Updated: May 07 2013 09:49:23 COT