// Command hashpw reads a single line (a passphrase) from stdin and prints // its Argon2id hash to stdout, with no other output. It exists so // build-host.ps1 can turn a passphrase into the string that gets baked // into host.exe via -ldflags, without duplicating the hashing logic // outside of Go. package main import ( "bufio" "fmt" "os" "strings" "lanrdp/internal/protocol" ) func main() { reader := bufio.NewReader(os.Stdin) line, err := reader.ReadString('\n') if err != nil && line == "" { fmt.Fprintln(os.Stderr, "hashpw: reading passphrase from stdin:", err) os.Exit(1) } line = strings.TrimRight(line, "\r\n") if len(line) < 8 { fmt.Fprintln(os.Stderr, "hashpw: passphrase must be at least 8 characters") os.Exit(1) } hash, err := protocol.HashPassword(line) if err != nil { fmt.Fprintln(os.Stderr, "hashpw:", err) os.Exit(1) } fmt.Print(hash) }