Welcome Guest, Not a member yet? Register   Sign In
Codeigniter mcrypt encode and decode
#1

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:

Code:
Array
(
   [product_key] => 5D6E-DR8R-ADDD-WQE5
   [name] => laptop
   [price] => 399.99
)


to encode with these parameters:

Code:
mcrypt_key='12som456ething99';
mcrypt_iv='fgdsd849848877ht';
mcrypt_mode='cbc';
mcrypt_cipher='rijndael-128';
 
and later to decode and print array.

Anyone?
Reply
#2

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.
Reply
#3

How to set these parameters first?

I know for serialize. How to write all that in CI?
Reply
#4

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.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB