[CryptoAPI] Hash always different value
Forge component by João Barata


I'm hashing passwords with CryptoAPI. To make it simple, just 1 time for each password. The problem is that I'm always getting a different result even if the input is always the same. So I made a page that Hashes the same password 30 times through the same action. To my knowledge it should always output the same value 30 times unless some salt has been added which I did not. Anyone who knows how to fix this?

I've tested this with SHA512 and bcrypt.



Hi Bo,

I suspect you are using function HashPassword, right ?

That function is meant to be used in conjunction with ComparePassword, you are not supposed to compare the output yourself (i.e. don't expect the value coming out to be equal strings)

If you use function ComputeHash from the same Forge Component instead, same value going in always gives you same value coming out (which you seem to be expecting)


Hi Dorine,

That is exactly what I did. I think I got a bit confused about the hash functions. Thanks for the clearification.



Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.