image

image

image

image

Ref: https://cheatsheetseries.owasp.org/cheatsheets/Password_Storage_Cheat_Sheet.html#password-hashing-algorithms

π–π‘πšπ­ 𝐒𝐬 𝐬𝐚π₯𝐭? According to OWASP guidelines, β€œa salt is a unique, randomly generated string that is added to each password as part of the hashing process”.

𝐇𝐨𝐰 𝐭𝐨 𝐬𝐭𝐨𝐫𝐞 𝐚 𝐩𝐚𝐬𝐬𝐰𝐨𝐫𝐝 𝐚𝐧𝐝 𝐬𝐚π₯𝐭? 1️ A salt is not meant to be secret and it can be stored in plain text in the database. It is used to ensure the hash result is unique to each password.

2️ The password can be stored in the database using the following format: 𝘩𝘒𝘴𝘩( 𝘱𝘒𝘴𝘴𝘸𝘰𝘳π˜₯ + 𝘴𝘒𝘭𝘡).

image

If you see in the above, password is never sent over wire to the server.

Go has input support using crypto for Argon2, bcrypt and PBKDF2

Using a slow, expensive hashing algorithm is recommended. These hashes introduce a calculation work factor which can then be scaled along with Moore’s Law. Some examples are Argon2, PBKDF2, bcrypt, and scrypt. While Argon2 is better, Bcrypt is still very good and scales with modern hardware due to the work factor. Go also provides us with a easy to implement library which makes this a good choice.