Connect to a Encrypted DB by C# System.Data.Sqlite
Hello there, I have an application that's written on C# that has an sqlite db, encrypted by System.Data.Sqlite, the connection string is:
var con = "Data Source=c:\Windows\xxxdb;Initial Catalog=RobotsMaster;Version=3;Integrated Security=SSPI;Password=0xhgasfw;"
Now I'm working on re-write the app using go-sqlite3, using:
db, err := sql.Open("sqlite3", "file:///C:/Windows/xxxdb?Password=0xhgasfw")
if err != nil {
log.Fatal(err.Error())
}
defer db.Close()
But I've got this error:
2014/12/12 09:25:32 file is encrypted or is not a database
It's possibly to use my encrypted db ?
Thanks !
2 years later...
Maybe you can use the SQLite.Interop.dll and rename it to sqlite3.dll and move it to the system folder.
Then compile go-sqlite3 with the parameters to use the installed SQLite library: --tags libsqlite3
Remember that you must to use a PRAGMA key='0xhgasfw' right after opening the database.
This library is a binding between SQLite3 and Golang, in order to open a encrypted Sqlite3 you have to use SQLCipher.
There are multiple golang bindings for it.
See: https://github.com/xeodou/go-sqlcipher
Can this be closed ?
The PRAGMA key is part of SQLCipher/
No, it is part of SQLite. It is just only enabled with additional code.
And System.Data.SQLite also has support for encryption as well as LiteReplica and LiteSync
Would be great if this library has encryption @mattn is working on it on the see branch I think.
I have added support for SQLCipher in the following PR: https://github.com/mattn/go-sqlite3/pull/1109