Documentation
¶
Index ¶
- func EncryptInPlace(path string, key []byte) error
- func IsPlaintext(path string) (bool, error)
- type Connector
- type Dialector
- func (d Dialector) BindVarTo(writer clause.Writer, stmt *gorm.Statement, v any)
- func (d Dialector) DataTypeOf(field *schema.Field) string
- func (d Dialector) DefaultValueOf(field *schema.Field) clause.Expression
- func (d Dialector) Explain(sql string, vars ...any) string
- func (d Dialector) Initialize(db *gorm.DB) error
- func (d Dialector) Migrator(db *gorm.DB) gorm.Migrator
- func (d Dialector) Name() string
- func (d Dialector) QuoteTo(writer clause.Writer, str string)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EncryptInPlace ¶ added in v1.1.1
EncryptInPlace converts the plaintext SQLite database at path into a SQLCipher-encrypted database keyed with key, atomically replacing the original.
This is a one-off migration for databases written by v1.0.0/v1.1.0, which opened the database without its key and therefore left it unencrypted on disk. Callers must only invoke it on a file already known to be plaintext (guard with IsPlaintext), and never concurrently with an open handle to the same file.
The plaintext original is left untouched until the encrypted copy has been written and verified, so an interrupted run simply retries on the next launch. No plaintext copy is retained afterwards.
This migration can be removed once no installs predate v1.1.1 (the release that keys the database).
func IsPlaintext ¶ added in v1.1.1
IsPlaintext reports whether the file at path is an unencrypted SQLite database (i.e. one written before the AES key was passed to the connection). A missing, empty or too-short file is not considered plaintext.
Types ¶
type Connector ¶
type Connector struct {
Path string
// contains filtered or unexported fields
}
Connector opens a SQLCipher database and sets the encryption key via PRAGMA key after the connection is established, keeping the key out of the DSN entirely.