Welcome Guest, Not a member yet? Register   Sign In
encrypt->decode does NOTHING.
#1

[eluser]loathsome[/eluser]
Hello.

I try to decode a string using the encrypt library, but nothing happens. I pasted from the manual as well
Quote:$encrypted_string = 'APANtByIGI1BpVXZTJgcsAG8GZl8pdwwa84';

echo $this->encrypt->decode($encrypted_string);

And I get nothing. I have set an encryption key in the config file. What the heck is this?? Encode works just fine.

Thanks.
#2

[eluser]Derek Allard[/eluser]
Be sure you are decode I a string that you'd previously encoded.

What happens if you run this?
Code:
function test()
    {
        $this->load->library('encrypt');

        $msg = 'One day, the robots will come for us';
        $encrypted_string = $this->encrypt->encode('My secret message');
        $plaintext_string = $this->encrypt->decode($encrypted_string);

        echo "<p>The original string was: $msg</p>";
        echo "<p>Encoded, that becomes: $encrypted_string</p>";
        echo "<p>If I take that encoded version, and run it through decode() I get: $plaintext_string</p>";
    }
#3

[eluser]loathsome[/eluser]
Hi Derek.

Your example does work, luckily, but the one copy/pasted from the user guide does not - which explains my confusion. I also tried it out with my own encoded strings, but after running your code everything seems to work now. (Maybe you snuck some evil robots in there? :O)

Anyway, you better fix up the documentation then. When I encode "My secret message", I get
Quote:4QLohIc7WHMrYV5fDpOCLwahLv2uDLpTbQ9YqbyFOKeje0cNhBf8pXcixIxtZensrjW+3Py7o6liqD6KNc+jgIlryfQtk3IWqiLeMX+jNotJbLQRCDJWDdcfxfRkHLkM

Maybe it's left from an older version or something Smile
#4

[eluser]Pascal Kriete[/eluser]
loathsome, the message depends on your encryption key. That way someone who doesn't know your key cannot decrypt it - which is the goal. The user guide doesn't say what encryption key it used, so you cannot decrypt that example. Make sense?
#5

[eluser]loathsome[/eluser]
Ah, of course!! I have no idea how I didn't think about that, and it makes perfect sense. *bashes head against wall*.

Stupid me Smile




Theme © iAndrew 2016 - Forum software by © MyBB