Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Connect to a Encrypted DB by C# System.Data.Sqlite #162

Open
x0d3r opened this issue Dec 12, 2014 · 6 comments
Open

Connect to a Encrypted DB by C# System.Data.Sqlite #162

x0d3r opened this issue Dec 12, 2014 · 6 comments
Projects

Comments

@x0d3r
Copy link

x0d3r commented Dec 12, 2014

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 !

@kroggen
Copy link

kroggen commented Jan 14, 2017

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.

@gjrtimmer
Copy link
Collaborator

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 ?

@gjrtimmer
Copy link
Collaborator

The PRAGMA key is part of SQLCipher/

@kroggen
Copy link

kroggen commented May 22, 2018

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

@gjrtimmer
Copy link
Collaborator

Would be great if this library has encryption @mattn is working on it on the see branch I think.

@gjrtimmer gjrtimmer added this to To do in SEE via automation May 30, 2018
gjrtimmer added a commit to gjrtimmer/go-sqlite3 that referenced this issue Jul 20, 2018
* Add DSN key
* Add PRAGMA execution
* Add SEE for external libsqlite3 library

Closes mattn#162
Closes mattn#487
@jgiannuzzi
Copy link

I have added support for SQLCipher in the following PR: #1109

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
SEE
  
To do
Development

No branches or pull requests

4 participants