restructured files, and updated for build outside
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"golang.org/x/crypto/bcrypt"
|
||||
)
|
||||
|
||||
// Usage: go run scripts/hashpass.go <password>
|
||||
// Outputs a bcrypt hash suitable for controller.yaml password_hash field.
|
||||
func main() {
|
||||
if len(os.Args) < 2 {
|
||||
fmt.Fprintf(os.Stderr, "Usage: %s <password>\n", os.Args[0])
|
||||
fmt.Fprintf(os.Stderr, "Generates a bcrypt hash for the felhom-controller config.\n")
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
password := os.Args[1]
|
||||
hash, err := bcrypt.GenerateFromPassword([]byte(password), bcrypt.DefaultCost)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "Error generating hash: %v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
fmt.Println(string(hash))
|
||||
}
|
||||
Reference in New Issue
Block a user