How to generate a memorable passphrase in Go
Step-by-step Go guide to generate a memorable passphrase. Use the browser tool for quick testing, then integrate the snippet into your application.
Last updated August 26, 2026
Steps
- 1
Open the passphrase generator tool and generate your value in the browser.
- 2
Copy the output — nothing is sent to a server; all processing is client-side.
- 3
Store secrets in environment variables or a secrets manager, never in source code.
- 4
Integrate the Go snippet below into your application.
- 5
Test end-to-end before deploying to production.
Code Example
import (
"crypto/rand"
"math/big"
"strings"
)
var words = []string{"correct","horse","battery","staple"}
func passphrase(n int) string {
out := make([]string, n)
for i := range out {
idx, _ := rand.Int(rand.Reader, big.NewInt(int64(len(words))))
out[i] = words[idx.Int64()]
}
return strings.Join(out, "-")
}Frequently Asked Questions
Is it safe to use the browser tool to generate a memorable passphrase?
Yes. All computation uses Web Crypto in your browser. No keys or tokens are transmitted to any server.
Can I use this Go code in production?
Yes, with proper secret storage. Replace placeholder values with environment variables and follow security best practices.
Continue
Related tools and reading on JWTSecrets.