Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does SHA-2 Hashing use a key?

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

like image 210
Marco Avatar asked Aug 29 '13 17:08

Marco


People also ask

How does SHA-2 hash work?

SHA-2 is an algorithm, a generalized idea of how to hash data. SHA-2 has several variants, all of which use the same algorithm but use different constants. SHA-256, for example, sets additional constants that define the behavior of the SHA-2 algorithm, one of these constants is the output size, 256.

Does hashing require a key?

The basic operation of hash functions does not need any key and operate in a one-way manner. The one-way operation means that it is impossible to compute the input from a particular output. The basic uses of hash functions are: Generation and verification of digital signatures.

Does SHA256 use keys?

SHA-256 is a patented cryptographic hash function that outputs a value that is 256 bits long. What is hashing? In encryption, data is transformed into a secure format that is unreadable unless the recipient has a key. In its encrypted form, the data may be of unlimited size, often just as long as when unencrypted.

What is SHA-2 encryption?

SHA-2 is the cryptographic hashing standard that all software and hardware should be using now, at least for the next few years. SHA-2 is often called the SHA-2 family of hashes because it contains many different-size hashes, including 224-, 256-, 384-, and 512-bit digests.


2 Answers

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.

like image 67
martinstoeckli Avatar answered Oct 05 '22 20:10

martinstoeckli


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.

like image 36
SLaks Avatar answered Oct 05 '22 20:10

SLaks