CodeIgniter Forums
encrypt->decode producing blank output - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: encrypt->decode producing blank output (/thread-26763.html)



encrypt->decode producing blank output - El Forum - 01-22-2010

[eluser]Wittner[/eluser]
Hi,

I've used the encryption library with CI before and have not had a problem, however at the moment, something is driving me nuts and I can't figure out why it won't work.

My database has a field which gets encrypted when I post a form. I can view the resulting encryption and it looks fine.

I then do a query, pull out the data and when I try to display the decoded encryption I get a blank. If I don't decode it, I can see the encrypted version of the field. Here is a cut-down version of the code. Can't see what's wrong here and as I say it's working perfectly on another app!

Code:
<?php foreach($query->result() as $item): ?>
...
<input type="text" name="customerName" value="<?=$this->encrypt->decode($item->customerName);?>" />
...
<?php endforeach; ?>

The outputted field value is blank!

Can anyone shed any light on this?


encrypt->decode producing blank output - El Forum - 01-22-2010

[eluser]danmontgomery[/eluser]
Incorrect encryption key in the config?


encrypt->decode producing blank output - El Forum - 01-22-2010

[eluser]Wittner[/eluser]
[SOLVED]
Thanks noctrum. I just figured it out. I had my fields set as varchar with a length of 35. I had forgotten that the encryption function can make the encrypted fields up to 3 or more times the length after encryption. I changed my fields to TEXT format and now it's working fine,

Just out of interest. Would it be a good idea to MD5 the result to end up with consistent sized results?

cheers,

Wittner


encrypt->decode producing blank output - El Forum - 01-22-2010

[eluser]Sbioko[/eluser]
Code:
<?php foreach($query->result() as $item): ?>
...
<input type="text" name="customerName" value="<?php echo $this->encrypt->decode($item->customerName); ?>" />
...
<?php endforeach; ?>



encrypt->decode producing blank output - El Forum - 01-22-2010

[eluser]Wittner[/eluser]
Thanks for pointing that out Demedes. I feel suitably chagrined and I shall change my php tags forthwith!

&lt;?php echo "cheers <br /> Wittner"; ?&gt;

;-)


encrypt->decode producing blank output - El Forum - 01-22-2010

[eluser]Sbioko[/eluser]
You are welcome! If you have any problems, just PM me!

Vadim


encrypt->decode producing blank output - El Forum - 01-22-2010

[eluser]danmontgomery[/eluser]
[quote author="Wittner" date="1264200176"][SOLVED]
Thanks noctrum. I just figured it out. I had my fields set as varchar with a length of 35. I had forgotten that the encryption function can make the encrypted fields up to 3 or more times the length after encryption. I changed my fields to TEXT format and now it's working fine,

Just out of interest. Would it be a good idea to MD5 the result to end up with consistent sized results?

cheers,

Wittner[/quote]

Ahh... Good to know.


encrypt->decode producing blank output - El Forum - 06-11-2012

[eluser]jpk[/eluser]
Hi Thank You. Its worked for me also.I have changed my field type to text from varchar.