Christmas Sale: 20% off on all products. Coupon code: FMECS2024

How to fix SodiumChachaIetf::decrypt() must be of the type string, boolean returned in Magento 2?

How to fix SodiumChachaIetf::decrypt() must be of the type string, boolean returned in Magento 2?

As the title indicates, this article will focus on how to fix the “SodiumChachaIetf::decrypt() must be of the type string, boolean returned in Magento 2” error. Before we focus on fixes, let’s understand what causes this error to appear.

Reasons for the SodiumChachaIetf::decrypt() Error

  • One of the reasons behind this error is when the encrypted data in your database is either corrupted, missing, or incorrectly formatted.
  • Another likely cause is that Magento cannot locate the encryption key in app/etc/env.php.
  • There’s also a possibility that the encryption may not match the one that was used to encrypt the data.
  • If you are restoring the database from another website or Magento version without the correct key, you may encounter this error.
  • Certain payment gateways rely upon API keys or encrypted keys. If there any issues in their configuration, you will encounter the above error.

Where Does the Error Appear?

The error can appear anywhere, but it usually occurs when:

  • When the admin is accessing or saving Magento 2 settings which involve encryption.
  • The checkout process, especially when processing the payment.
  • During the cron jobs.

How to Fix the Issue?

1. Clear the Cache

Before opting for the more challenging fixes, go for the easiest one first. In most cases, clearing the cache is likely to resolve the issue. The following commands will help you clear the cache:

php bin/magento cache:clean

php bin/magento cache:flush

2. Reinstall the Module

If you experienced the error after installing a module such as a payment module, you will need to remove it. Check if the error persists. If not, then ensure that you are installing a stable version and not the beta.

3. Check the Encryption Keys

If the encryption key is missing or incorrect, you have two options – restore it from a backup or from the original installation. If neither of this is possible, we fear that you will never be able to access your data.

4. Update the Sodium Library

First, ensure that the sodium library is installed by using the below command:

php -m

If it is not installed, install it by using:

apt-get install php-sodium

Once complete, restart the apache.

5. Update to the Latest Magento Version

If the error continues to persist, there is a chance that it is due to your current Magento version. Therefore, you need to update it to the latest version. Prior to doing so, don’t forget to turn on the maintenance mode and take a backup. There are 3 ways to update Magento to the latest version. You can opt for the web setup wizard, the composer, or manual update method. The web setup wizard is the easiest method out of the 3.

6. Restore from a Backup

If the above methods don’t fix your issue, restore your Magento 2 using a backup prior to the issue appearing on your screen. Verify that the issue is resolve once the restore is complete.

7. Contact a Magento Development Company

If you have exhausted all your options, the only thing left to do is contact a Magento Development Company such as FME. In FME’s case, our developers will identify the issue by undertaking a comprehensive analysis of your store. Based on this analysis, they will share the most appropriate fix and provide you with a detailed report of what was done.

Conclusion

This concludes our article on how to fix the SodiumChachaIetf::decrypt() error in Magento 2. As you can see for yourself, fixing the error requires nothing but patience. You may need to apply multiple fixes before you fix the error. If you still have any queries, don’t hesitate to reach out to us.

Read More Magento 2 Blogs:

This blog was created with FME's SEO-friendly blog