go-sqlite icon indicating copy to clipboard operation
go-sqlite copied to clipboard

How to encrypt database ?

Open barats opened this issue 2 years ago • 2 comments

Thanks for ur amazing work on https://github.com/glebarez/go-sqlite, which is VERY great project.

BTW, is there any possible way to encrypt database without relying on CGO?

barats avatar Sep 05 '22 09:09 barats

Let me forward all your credits to modernc.org/sqlite, since this repo is just a fork with minimal changes:

modernc.org/sqlite consists of:

  1. pure go implementation of SQLite (original C codebase is regularly transpiled into Go with great tools from modernc.org
  2. implementation for golang database/sql driver interface as described in https://pkg.go.dev/database/sql/driver

glebarez/go-sqlite: is just a fork of modernc/sqlite with slight changes in the driver part (2), to behave more closely to mattn’s CGo version (https://github.com/mattn/go-sqlite3). this slight changes allowed it to be fully compatible with GORM (the GORM driver is in https://github.com/glebarez/sqlite)

Now, back to your question, I am assuming you mean translating some encryption-enabled fork of SQLite (e.g. https://github.com/sqlcipher/sqlcipher) into Go ? This is only possible if developer of https://gitlab.com/cznic/sqlite will try to transpile it into Go. There's already an issue for it: https://gitlab.com/cznic/sqlite/-/issues/105

glebarez avatar Sep 05 '22 17:09 glebarez

Thanks for ur reply.

Let me come back to this issue later. I'm new to sqlite3, I might need to dig in a little bit.

barats avatar Sep 06 '22 02:09 barats