Welcome Guest, Not a member yet? Register   Sign In
encrypt->decode producing blank output
#1

[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?
#2

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

[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
#4

[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; ?>
#5

[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;

;-)
#6

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

Vadim
#7

[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.
#8

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




Theme © iAndrew 2016 - Forum software by © MyBB