Mathematical algorithms that transform input data into a fixed-length sequence of characters, referred to as a hash value.
- They are fast, deterministic and one way. The cipher text cannot be used to reconstruct the plain text.
- They provide data verification and authentication.
Example
- MD5 (Message-Digest Algorithm 5) (deprecated)
- SHA (Secure Hash Algorithm)
Hashing can be used to store passwords in the database. Although, in case the database gets compromised, hackers can make use of rainbow tables to match commonly used passwords. We make use of salted password hashing to solve this problem
Note
Since hash outputs are fixed-length sequences of bits, they are commonly displayed in encoded formats rather than raw binary. The two most frequent representations are Hexadecimal and Base64, which provide a more human-readable string.
Salt
A salt is a random value that you can add to the data before hashing. This makes each hash unique and significantly enhances your security. The salt is then concatenated to the hashed value for verifying the password later.
Password Storage Process
- Input:
password+salt- Process: Apply Hashing Function
- Result:
salted hashed password- Storage:
salted_hash+:+salt(Stored in DB)