Hi all,

I'm using mcrypt to encrypt a string of text (a session-specific code), but I need to store it on a client-side cookie.

I've written a 'test' script to ensure that my encryption is working properly by encrypting and decrypting directly to server-side PHP variables, which seems to work fine. I can enter strings of text that are quite long and they are encrypted and decrypted properly.

Then I have the script that I use to store the key in a session variable (the key used to encrypt the code I want to store in the cookie), and then store the encrypted string in a cookie. If the string isn't that long, it's decrypted fine... but anything much longer than 12-15 characters, the rest of the string is output as garbage. I suspect that cookies are the problem.

Now, I'm pretty sure (from what I've read) that the output from the mcrypt generic function is a binary string and not a 'character' string. So I'm curous whether anyone knows if I can store this data as-is in a cookie, or whether cookies will ONLY accept character data. And if so, does anyone know how I might be able to convert the binary data to character data, and vice versa under PHP?

Thanks,

  • coredumped.
    Write a Reply...