Use mcrypt_encrypt()
and mcrypt_decrypt()
with corresponding parameters. Really easy and straight forward, and you use a battle-tested encryption package.
EDIT
5 years and 4 months after this answer, the mcrypt
extension is now in the process of deprecation and eventual removal from PHP.