If you made a hash function that worked like this:

SHA(std::hash(T input)

Would it be a secure hash? The reason I am asking is that std::hash provides a template input, which is much more convenient than the alternative provided by Crypto++, which requires a string input.


Cryptographic hash function should be collision resistant, i.e., nobody should be able to find two inputs having the same hash value. For non-cryptographic hash functions (like std::hash) this is not required, so someone might be able to find two inputs having the same output on std::hash.

Always ask yourself: What happens if you apply SHA to these outputs? Do you get a collision of your construction?

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.