Screenshot 2024-08-02 at 6.14.04 PM.png

Hashing is a process that transforms input data (of any size) into a fixed-size string of characters.

Hash functions have several important properties:

  1. Deterministic: The same input will always produce the same output.
  2. Fast computation: The hash value can be quickly computed for any given data.
  3. Pre-image resistance: It should be computationally infeasible to reverse the hash function (i.e., find the original input given its hash output).
  4. Small changes in input produce large changes in output: Even a tiny change in the input should drastically change the hash output.
  5. Collision resistance: It should be computationally infeasible to find two different inputs that produce the same hash output.

Is this a hashing algorithm?

What if I try “hashing” a string by increasing each alphabet’s value by one. Do you think this follows all the rules we’ve written above?

Screenshot 2024-08-02 at 6.23.53 PM.png

SHA-256

Lets try out a famous hash function, SHA-256 here - https://emn178.github.io/online-tools/sha256.html

Screenshot 2024-08-02 at 6.18.42 PM.png

Node.js code for generating SHA-256