sqlcipher

package
v1.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 22, 2026 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EncryptInPlace added in v1.1.1

func EncryptInPlace(path string, key []byte) error

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

func IsPlaintext(path string) (bool, error)

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.

func NewConnector

func NewConnector(path string, key []byte) *Connector

func (*Connector) Connect

func (c *Connector) Connect(_ context.Context) (driver.Conn, error)

func (*Connector) Driver

func (c *Connector) Driver() driver.Driver

type Dialector

type Dialector struct {
	Connector *Connector
}

Dialector implements gorm.Dialector for SQLCipher.

func (Dialector) BindVarTo

func (d Dialector) BindVarTo(writer clause.Writer, stmt *gorm.Statement, v any)

func (Dialector) DataTypeOf

func (d Dialector) DataTypeOf(field *schema.Field) string

func (Dialector) DefaultValueOf

func (d Dialector) DefaultValueOf(field *schema.Field) clause.Expression

func (Dialector) Explain

func (d Dialector) Explain(sql string, vars ...any) string

func (Dialector) Initialize

func (d Dialector) Initialize(db *gorm.DB) error

func (Dialector) Migrator

func (d Dialector) Migrator(db *gorm.DB) gorm.Migrator

func (Dialector) Name

func (d Dialector) Name() string

func (Dialector) QuoteTo

func (d Dialector) QuoteTo(writer clause.Writer, str string)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL