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

Crypt error

I am trying to decrypt a password using decryptBase64 but i got this error


Phalcon\Crypt\Exception: Size of IV is larger than text to decrypt

on my services.php i have


$di->set('crypt', function () use ($config) {
    $crypt = new Crypt();
    $crypt->setMode(MCRYPT_MODE_CBC);
    $crypt->setCipher(MCRYPT_RIJNDAEL_128);
    $crypt->setKey($config->application->cryptSalt);
    return $crypt;
}, true);

here is the code to decrypt


$this->crypt->decryptBase64(self::$u_pass);

here is the code to encypt


self::$password     = $this->crypt->encryptBase64(self::$password);


55.9k
Accepted
answer

owwww just figured it out,


$this->crypt->decryptBase64(self::$u_pass);

was trying to decrypt the password which is not yet encrypted. So it should be


$this->crypt->decryptBase64($encyptedpasswordfromdatabase);