使用mcrypt和sha-512加密解密?

I have gotten a code from php.net. http://php.net/manual/en/book.mcrypt.php

Problem is when you encrypt something, the next time the ecrypted one isn't the same as the first one. I need to get the exact same hash using sha512 or sha256. I also need to decrypt it because the function will be used for encrypting customer's name and other data.

Thanks in advance!

Instead of using mcrypt for hashing, consider using the hash() function instead.

Remember, hashes is one-way methods and cannot be 'decrypted'.

Looking for encryption/decryption I would recommend you look at AES encryption - either through MySQL if you have your data stored in the database, otherwise mcrypt() can also manage AES.

I shared my crypt wrapper at https://stackoverflow.com/a/173764/17404. Try using that.