/gorm-sqlcipher-v4

A gorm-sqlcipher module that uses the v4 version of github.com/mutecomm/go-sqlcipher

Primary LanguageGoGNU General Public License v3.0GPL-3.0

gorm-sqlcipher-v4

The existing gorm-sqlcipher modules I tried all threw the same errors when using gorm v1.25.11. I cloned one of the repos, patched the bugs, and created a new working module. Enjoy.

Installation

go get github.com/gdanko/gorm-sqlcipher-v4

How to use

import (
	sqlcipher "github.com/gdanko/gorm-sqlcipher-v4"
	"gorm.io/gorm"
)

key := "2DD29CA851E7B56E4697B0E1F08507293D761A05CE4D1B628663F411A8086D99"
dbFile := "/path/to/my.db"
dbName := fmt.Sprintf("%s?_pragma_key=x'%s'&_pragma_cipher_page_size=4096", dbFile, key)
db, err := gorm.Open(sqlcipher.Open(dbName), &gorm.Config{})

More