Haylo
Haylo

Reputation: 3

What is the point of hashing?

A typical example of hashing use would be the storage of passwords or sensitive data because this form of encryption is irreversible, but if it cannot be decrypted, why store it? The only possible use (from my limited knowledge) would be to have a user enter a password, have a program hash it and then check whether the user input hash is the same as the stored hash for said user. Is that a (or the only) correct scenario? What am I missing here? If that isn't the case, then how are passwords checked for correctness, and why not just delete the data instead of one-way encrypt it?

Upvotes: 0

Views: 374

Answers (1)

gusto2
gusto2

Reputation: 12075

A typical example of hashing use would be the storage of passwords

Purpose of the hash (generally) is to create a fixed-size thumbprint of input of any size. Cryptographic hash has extra properties - the most important in this context it is hard (impossible) to derive any information about the input and create a duplicate (intentionally or not).

So there are other uses of a hash function:

  • anonymizing data
  • integrity check, that data are not changed
  • referencing large content
  • ...

but if it cannot be decrypted, why store it?

Because we could compare if two contents are the same without needing to know or read the content itself.

or sensitive data because this form of encryption is irreversible

No, not storing any information. Hash is not any form of encryption.

The only possible use (from my limited knowledge) would be to have a user enter a password, have a program hash it and then check whether the user input hash is the same as the stored hash for said user. Is that a (or the only) correct scenario?

Basically yes. Reality is a little bit more complex, for storing the user credentials the best known option today we have is slow salted hash, so PBKDF2, BCrypt, SCrypt or Argon2.

and why not just delete the data instead of one-way encrypt it?

Because you need to compare the user password (it's hash) if it is correct. Or to check if some data are not changed.

Upvotes: 1

Related Questions