How do I use the sha512 function for PHP?
Can I replace all my md5 functions with the sha512 function?
Do I have to download something if so what?
Can anyone provide examples?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The
hash()function, provided with PHP >= 5.1, should be able to generate sha512 hashes — you can verify this calling thehash_algos()function, that lists the supported hashing algorithms.For example, you could use :
And you’d get :
And, on my system, the following portion of code :
Indicates that 42 hashing algorithms are supported :
Also, with PHP >= 5.3, you should be able to use the
openssl_digest()function :(Yep, the parameters are not in the same order as with
hash()— the magic of PHP, here…)And, to get the list of supported algorithms, you could use
openssl_get_md_methods().On my system, this one gives me 22 supported algorithms.