Intro to hashing
Hashing is a process that transforms input data (of any size) into a fixed-size string of characters.
Hash functions have several important properties:
- Deterministic: The same input will always produce the same output.
- Fast computation: The hash value can be quickly computed for any given data.
- Pre-image resistance: It should be computationally infeasible to reverse the hash function (i.e., find the original input given its hash output).
- Small changes in input produce large changes in output: Even a tiny change in the input should drastically change the hash output.
- 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?
SHA-256
Lets try out a famous hash function, SHA-256 here - https://emn178.github.io/online-tools/sha256.html
Node.js code for generating SHA-256
const crypto = require('crypto');
const input = "100xdevs";const hash = crypto.createHash('sha256').update(input).digest('hex');
console.log(hash)