diff --git a/cmd/README.md b/cmd/README.md new file mode 100644 index 00000000..2515a239 --- /dev/null +++ b/cmd/README.md @@ -0,0 +1,6 @@ + +To run the hasher, do like this + +```bash +$ go run hasher.go hunter2 +``` diff --git a/cmd/hasher.go b/cmd/hasher.go new file mode 100644 index 00000000..d3c3459f --- /dev/null +++ b/cmd/hasher.go @@ -0,0 +1,18 @@ +package main + +import ( + "fmt" + "os" + + "golang.org/x/crypto/bcrypt" +) + +func main() { + password := os.Args[1] + + hash, err := bcrypt.GenerateFromPassword([]byte(password), bcrypt.DefaultCost) + if err != nil { + fmt.Println("Error generating hash: %s", err) + } + fmt.Println(string(hash)) +}