You want to encrypt and decrypt data using one of a variety of popular algorithms.
$key = 'That golden key that opes the palace of eternity.'; $data = 'The chicken escapes at dawn. Send help with Mr. Blue.'; $alg = MCRYPT_BLOWFISH; $mode = MCRYPT_MODE_CBC; $iv = mcrypt_create_iv(mcrypt_get_iv_size($alg,$mode),MCRYPT_DEV_URANDOM); $encrypted_data = mcrypt_encrypt($alg, $key, $data, $mode, $iv); $plain_text = base64_encode($encrypted_data); print $plain_text."\n"; $decoded = mcrypt_decrypt($alg,$key,base64_decode($plain_text),$mode,$iv); print $decoded."\n"; NNB9WnuCYjyd3Y7vUh7XDfWFCWnQY0BsMehHNmBHbGOdJ3cM+yghABb/XyrJ+w3xz9tms74/a70= The chicken escapes at dawn. Send help with Mr. Blue.
mcrypt extension is an interface with
mcrypt, a library that implements many different
encryption algorithms. The data is encrypted and decrypted by
mcrypt_decrypt( ), respectively. They each take
five arguments. The first is the algorithm to use. To find which
mcrypt supports on your system, call
. The full list of
algorithms is shown in Table 14-1. The second
argument is the encryption key; the third argument is the data to
encrypt or decrypt. The fourth argument is the
for the encryption or decryption (a list of supported modes is
). The fifth argument is an
initialization vector (IV), used by ...