views:

30

answers:

1

I see base64_encode can encode values, but without a key. I need a function that takes a salt and data, encodes it, and can be decoded with the same salt (but if you try to decode it without the salt, it gives you gibberish).

Is there a PHP function for this (can't find it, only modified versions of base64_encode).

EDIT: Found the answer: use mcrypt ciphers

+2  A: 

What about taking a look at http://www.php.net/manual/en/book.mcrypt.php

Jason Lewis
You could generate the key like this; $key = md5(rand()+time()); Ideally you'd improve that algorithm however
Ben Rowe