Documentation
¶
Overview ¶
Package crypto is the pgcrypto extension: hashing, password hashing and symmetric encryption on the server. Needs CREATE EXTENSION pgcrypto.
Hashing passwords on the server sends the plain password over the wire and into the statement log. Prefer hashing in Go and storing the hash; these helpers exist for schemas that already commit to pgcrypto.
Index ¶
- Variables
- func Crypt(password, salt sqlb.Expr[string]) sqlb.Expr[string]
- func Digest(data sqlb.Expr[string], algo string) sqlb.Expr[[]byte]
- func GenRandomBytes(n int) sqlb.Expr[[]byte]
- func GenSalt(typ string, rounds int) sqlb.Expr[string]
- func HMAC(data, key sqlb.Expr[string], algo string) sqlb.Expr[[]byte]
- func PgpSymDecrypt(data sqlb.Expr[[]byte], key sqlb.Expr[string]) sqlb.Expr[string]
- func PgpSymEncrypt(data, key sqlb.Expr[string]) sqlb.Expr[[]byte]
Constants ¶
This section is empty.
Variables ¶
var Extension = pg.Extension{Name: "pgcrypto"}
Extension is the pgcrypto extension this package's constructs need, for pg.CreateExtension(Extension), so a library installs what it uses without spelling its name.
Functions ¶
func GenRandomBytes ¶
GenRandomBytes renders gen_random_bytes(n).
func GenSalt ¶
GenSalt renders gen_salt(type, rounds); type is "bf", "md5", "xdes" or "des" and rounds is the bcrypt cost.
func PgpSymDecrypt ¶
PgpSymDecrypt renders pgp_sym_decrypt(data, key), the reverse of PgpSymEncrypt. It returns text, so the ciphertext column is []byte and the result is a string.
Types ¶
This section is empty.