wip
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
// tools/hashpwd generates a bcrypt hash for use in config.yaml.
|
||||
//
|
||||
// Usage:
|
||||
//
|
||||
// go run ./tools/hashpwd mysecretpassword
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"golang.org/x/crypto/bcrypt"
|
||||
)
|
||||
|
||||
func main() {
|
||||
if len(os.Args) < 2 {
|
||||
fmt.Fprintln(os.Stderr, "usage: hashpwd <password>")
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
password := os.Args[1]
|
||||
hash, err := bcrypt.GenerateFromPassword([]byte(password), bcrypt.DefaultCost)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "error: %v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
fmt.Println(string(hash))
|
||||
}
|
||||
Reference in New Issue
Block a user