Does SHA-2 Hashing use a key?

11.2k views Asked by At

From personal knowledge I know SHA-2 hashes are irreversible and do not use a key.

But a person I know has contradicted the above very confidently, I'm now confused and couldn't find the answer I wanted by googling.

Can anyone clear me up on this issue ?

Thanks

2

There are 2 answers

1
SLaks On

SHA-2, like all hash algorithms, do not use keys.

The definition of a hash function is a map from a single input to an output.

0
martinstoeckli On

Hash functions like SHA-* do not need a key, they just calculate a hash-value from any input.

There are other functions like HMAC, which indeed use a key, together with a hash function. So it is possible to use a key together with SHA-2, to generate a HMAC, that's what the person possibly had in mind, and what SLaks tried to point out. A HMAC has a different purpose than a hash function though.