Amazon Interview Question
Software Engineer / Developers1. Hashing is one way process used to secure things like passwords etc.
2. Encryption is reversible process to encrypt original content and then decrypt it back again using keys.
A good analogy I read on Stack Overflow (bad I cannot post actual link, //stackoverflow/questions/4948322/fundamental-difference-between-hashing-and-encryption-algorithms)
A hash function could be considered the same as baking a loaf of bread. You start out with inputs (flour, water, yeast, etc...) and after applying the hash function (mixing + baking), you end up with an output: a loaf of bread.
Encryption, on the other hand, could be viewed as a safe deposit box. Whatever you put in there comes back out, as long as you possess the key with which it was locked up in the first place. It's a symmetric operation. Given a key and some input, you get a certain output. Given that output, and the same key, you'll get back the original input. It's a 1:1 mapping.
Another difference apart from what @RV mentioned -
1) A hash function takes an input and provides a short unique representation of the input. Anyone who has access to the hash function can get the same output for the given input.
However, an encryption function needs a secret key to get the output.
2) The purpose of hashing is to get integrity of data. The purpose of encryption is to get confidentiality.
May be Encryption will have a reverse algorithm for decryption and to get back the original value.
- Thiyanesh January 22, 2010With hashing, its not possible to get the original value from the hash output.