Files
orchestra/cmd/orchestra-password/main.go
T
2026-07-30 14:34:29 +04:00

28 lines
607 B
Go

// orchestra-password prints a bcrypt hash suitable for ORCHESTRA_WEB_PASSWORD_HASH.
package main
import (
"fmt"
"os"
"syscall"
"golang.org/x/crypto/bcrypt"
"golang.org/x/term"
)
func main() {
fmt.Fprint(os.Stderr, "Password: ")
password, err := term.ReadPassword(int(syscall.Stdin))
fmt.Fprintln(os.Stderr)
if err != nil || len(password) == 0 {
fmt.Fprintln(os.Stderr, "password is required")
os.Exit(1)
}
hash, err := bcrypt.GenerateFromPassword(password, bcrypt.DefaultCost)
if err != nil {
fmt.Fprintln(os.Stderr, "hash password:", err)
os.Exit(1)
}
fmt.Println(string(hash))
}