bcrypt

command
v0.0.0-...-8c2c48f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 31, 2024 License: MIT Imports: 3 Imported by: 0

README

Imagine you want to store your secret passwords safely on your computer. This Golang code is like a tool to securely store and check those passwords.

The Thought Process:

  1. Problem: We can't store passwords directly because someone might steal them.
  2. Solution: Hashing: The code uses a special process called hashing to turn your password into a scrambled mess (hash) that can't be easily turned back into the original password. It's like turning your secret message into a weird code that only you and the tool understand.
  3. Security: It's important to make this hash strong, so it takes a long time to crack. The code uses a setting called "cost" to control how strong the hash is.
  4. Checking Passwords: When you want to log in, you enter your password. The code turns it into a hash again and compares it to the stored hash (like checking your weird code against the original one). If they match, then your password is correct.

Step-by-Step Breakdown:

  • There's a pre-generated, scrambled password stored in the code (storedHash). Imagine this is the secure version of your real password stored on the computer.
  • When you run the program, it asks you to type your password.
  • The code turns your password into a scrambled hash using a strong setting (bcrypt.DefaultCost).
  • It compares the newly created hash to the stored one (storedHash).
  • If the hashes match, it means your password is correct (like your weird code matching the stored one).

Decisions Made:

  • The code uses a secure hashing algorithm called bcrypt.
  • It sets the cost to a default strong level for added security.
  • It logs messages to tell you if the password is correct or not.

Remember: This is a simplified explanation. In real use, passwords should be stored in a secure database and not directly in the code.

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL