How do I encode something in PHP with a key? <p>I see <code>base64_encode</code> 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).</p> <p>Is there a PHP function for this (can't find it, only modified versions of <code>base64_encode</code>).</p> <p>EDIT: Found the answer: use <a href="http://www.php.net/manual/en/mcrypt.ciphers.php" rel="nofollow noreferrer">mcrypt ciphers</a></p>