CodeIgniter Forums

Full Version: Codeigniter mcrypt encode and decode
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Can anyone help me on how to set a few parameters in codeigniter and encode and decode an array? I was looking over a few hours on the Internet and didn't find any answer.

I'm looking for something like this, to take some array:

   [product_key] => 5D6E-DR8R-ADDD-WQE5
   [name] => laptop
   [price] => 399.99

to encode with these parameters:

and later to decode and print array.

All you need to do is serialize the array before you encode it, and then unserialize the array after you decode it. Look in the PHP manual for serialize and unserialize functions.
How to set these parameters first?

I know for serialize. How to write all that in CI?
I don't see anything in the docs where you can set your own IV. I don't think it's possible using the CI3.0.X Encryption library. Maybe somebody (like Narf) can tell you a solution.