crypt
Go crypto with safe defaults (AES-GCM, ChaCha20-Poly1305, argon2id, HMAC, Ed25519, key rotation), byte-compatible with crypt-ts.
go get github.com/ubgo/crypt
- Language
- Go
- Go version
- 1.25.0
- Core deps
- 1 direct
- Latest tag
- v0.2.0
- License
- Apache-2.0
- Go modules
- 1
Highlights from the README
- AES-CBC instead of GCM (no authentication).
- A “default” key string committed to source.
bytes.Equalfor HMAC verification (timing leak).- Argon2 with hand-tuned parameters that drift from OWASP recommendations.
- A wire format that the Node sibling decodes wrong for any plaintext > 16 bytes.
Code from the README
import "github.com/ubgo/crypt"
key, _ := crypt.RandomBytes(crypt.AEADKeySize)
ct, _ := crypt.Seal(key, []byte("hello, world"), nil)
pt, _ := crypt.Open(key, ct, nil)
// pt == []byte("hello, world")sealer, _ := crypt.NewSealer(appKey) // 32 bytes from secrets manager
enc, _ := sealer.Seal([]byte(secret), nil)
db.Exec(`UPDATE partners SET client_secret = $1 WHERE id = $2`, enc, id)
plain, _ := sealer.Open(row.ClientSecret, nil)ct, _ := sealer.Seal(payload, []byte("user:"+userID))
pt, err := sealer.Open(ct, []byte("user:"+userID))
// err == ErrTampered if userID differs from issue timeFrom the crypt README.