Reputation: 46
I have encrypted email Address like
$this->load->library('encrypt');
$encoded = $this->encrypt->encode('user_email_address');
In codeigniter
Model.
And after that when I tried to decode, it does not show the correct data.
$this->encrypt->decode('user_email_address');
It shows like
Jts¹+…Ru\¼A·¾Àp¤c’áµSîÆKÆ—l¿Ýƒ>ü«%c‚µ~SÔNÏŠÖä3; ñÑ
Please help me to solve this issue
Thanks in advance.
Upvotes: 1
Views: 762
Reputation: 714
set encryption_key based on the algorithm used for encryption. eg. for AES-128, encryption key must be 128 bits or 16 bytes (characters) long. Or you can create key in your function itself before calling encode() function like:
$key = $this->encryption->create_key(16);
for more details : refer https://www.codeigniter.com/user_guide/libraries/encryption.html
Upvotes: 0
Reputation: 1184
You can't use directly email to decode
Use it as
$this->load->library('encrypt');
$encodedEmail = $this->encrypt->encode('user_email_address');
$myEmail = $this->encrypt->decode($encodedEmail);
Upvotes: 2