Got an error "Decrypting: authentication failed" while using Encryption service |
Hi, in my project I need to store category id in category edit page inside a hidden field. Then, after form submit I want to update that particular category. To achieve this, in a secured approach, I used Encryption service of CodeIgniter 4.
Note: In the App\Config\Encryption.php file, I already set the "base 64" encoded value for "key" property that I got after executing createKey() static function of the Encryption class. Also, I included that Encryption class with its namespace that is "CodeIgniter\Encryption\Encryption". Below code is for the editCategory function, where I create the encryption key, then using that key I encrypt category id. Finally, I pass that to the "edit_category" view file. PHP Code: public function editCategory($categoryId) { In edit_category.php file, I pass the encrypted category id to the updateCategory function. Code snippet for hidden field in edit_category.php is written below. PHP Code: <input type="hidden" name="categoryId" value="<?= isset($categoryId) ? $categoryId : '' ?>"> Codes for updateCategory function is shown below, in that function I wanted to display the decrypted version of the category id. PHP Code: public function updateCategory() { Have I done any mistake? Please help. |
Messages In This Thread |
Got an error "Decrypting: authentication failed" while using Encryption service - by nileshsanyal - 09-25-2020, 05:22 AM
RE: Got an error "Decrypting: authentication failed" while using Encryption service - by paulbalandan - 09-25-2020, 09:19 AM
RE: Got an error "Decrypting: authentication failed" while using Encryption service - by nileshsanyal - 09-27-2020, 12:50 AM
|