package configgen import ( "crypto/rand" _ "embed" "math/big" "strings" ) //go:embed hungarian.txt var hungarianWords string // wordList is populated from the embedded hungarian.txt at init time. var wordList []string func init() { seen := make(map[string]struct{}, 30000) for _, line := range strings.Split(hungarianWords, "\n") { w := strings.TrimSpace(line) if w == "" { continue } if _, dup := seen[w]; dup { continue } seen[w] = struct{}{} wordList = append(wordList, w) } } // RandomPassphrase generates a human-friendly passphrase from Hungarian words. // Format: "szó-szó-szó-szó-szó" (words separated by dashes). // With a ~29K word list, 4 words gives ~59 bits of entropy, 5 words ~74 bits. // Easy to read, type, and dictate by Hungarian-speaking customers. func RandomPassphrase(wordCount int) (string, error) { words := make([]string, wordCount) max := big.NewInt(int64(len(wordList))) for i := range words { idx, err := rand.Int(rand.Reader, max) if err != nil { return "", err } words[i] = wordList[idx.Int64()] } return strings.Join(words, "-"), nil }