Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Caracorn's avatar

Decrypt -> The payload is invalid

Hello, I encrypted a password with salt, then decrypted it.

$pw = encrypt( $request->input( 'password' ) . $salt );

Then I saved it in the database. After loading it again and decrypted it, I got the error message: The payload is invalid.

$pw = $this->removeSalt(decrypt($result->password));

What's wrong?

0 likes
2 replies
bobbybouwmann's avatar

The encrypt method is already salting the data, so you don't need to do that yourself as well!

This should work fine

$password = 'pass1234';

$encryptedPassword = encrypt($password);
$decryptedPassword = decrypt($encryptedPassword);

$password == $decryptedPassword // true
3 likes

Please or to participate in this conversation.