Explain difference between Hashing and Encryption algorithms

Technology CommunityCategory: CryptographyExplain difference between Hashing and Encryption algorithms
VietMX Staff asked 3 years ago
  • Hash Functions provide a mapping between an arbitrary length input, and a (usually) fixed length (or smaller length) output. 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.

    Going the other way is extraordinarily difficult – you can’t really separate the bread back into flour, water, yeast – some of that was lost during the baking process, and you can never tell exactly how much water or flour or yeast was used for a particular loaf, because that information was destroyed by the hashing function (aka the oven).

    Many different variants of inputs will theoretically produce identical loaves (e.g. 2 cups of water and 1 tsbp of yeast produce exactly the same loaf as 2.1 cups of water and 0.9tsbp of yeast), but given one of those loaves, you can’t tell exactly what combo of inputs produced it.

  • Encryption Functions provide a 1:1 mapping between an arbitrary length input and output. And they are always reversible. The important thing to note is that it’s reversible using some method. And it’s always 1:1 for a given key. Encryption 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.