How to use SQLCipher with SQLite net

Minafawzy.0454Minafawzy.0454 USMember ✭✭✭

I am using Sqlite according to documentation I can encrypt my database with SQLCipher

but I dont know how to use it I just update my sqlite version but what is next

https://github.com/ericsink/SQLitePCL.raw/wiki/How-to-use-SQLCipher-with-SQLite-net

Best Answer

Answers

  • anaselhajjajianaselhajjaji USMember ✭✭

    By using the Xamarin Component, it's transparent. You only need to change the namespace to: Mono.Data.Sqlcipher.
    Only one thing, after instantiating SqliteConnection call connection.SetPassword(yourPassword) then Open(). That's all...

  • Minafawzy.0454Minafawzy.0454 USMember ✭✭✭

    @Anas EL HAJJAJI could you please give me sample code I cant open connection by this way

  • Minafawzy.0454Minafawzy.0454 USMember ✭✭✭

    @Albert Kay thanks man you save my day , but after add password to my database I cant open it with sqlite browser even I enter correct password xzy1921

    var t = conn.Query<int>("PRAGMA key=xzy1921");

  • Minafawzy.0454Minafawzy.0454 USMember ✭✭✭

    I face error in decrypting the file

    here how I use the method var t = await db.QueryAsync("PRAGMA key=xyz123");

    what is wrong with my method

  • AlbertKAlbertK MYMember ✭✭✭

    Hi,

    That is the whole purpose, not to have a third party app to open the DB. The database is now encrypted and Sqlite browser or any sql browser should not be able to open it. If you would like to open the encrypted DB then you have to get a browser that can open it like SQLiteManager.

    https://www.zetetic.net/sqlcipher/buy/

  • AlbertKAlbertK MYMember ✭✭✭

    Hi,

    That is the whole purpose, not to have a third party app to open the DB. The database is now encrypted and Sqlite browser or any sql browser should not be able to open it. If you would like to open then you have to get a browser that can open it buy like SQLiteManager. BTW, the nuget package

    https://www.zetetic.net/sqlcipher/buy/

  • AlbertKAlbertK MYMember ✭✭✭

    Hi,

    That is the whole purpose, not to have a third party app to open the DB. The database is now encrypted and Sqlite browser or any sql browser should not be able to open it. If you would like to open then you have to get a browser that can open it buy like SQLiteManager. BTW, the nuget package

    https://www.zetetic.net/sqlcipher/buy/

  • AlbertKAlbertK MYMember ✭✭✭

    Hi,

    That is the whole purpose, not to have a third party app to open the DB. The database is now encrypted and Sqlite browser or any sql browser should not be able to open it. If you would like to open then you have to get a browser that can open it buy like SQLiteManager. BTW, the nuget package

    https://www.zetetic.net/sqlcipher/buy/

  • AlbertKAlbertK MYMember ✭✭✭

    Hi,

    That is the whole purpose, not to have a third party app to open the DB. The database is now encrypted and Sqlite browser or any sql browser should not be able to open it. If you would like to open the encrypted DB then you have to get a browser that can open it like SQLiteManager.

    https://www.zetetic.net/sqlcipher/buy/

  • AlbertKAlbertK MYMember ✭✭✭

    Hi,

    That is the whole purpose, not to have a third party app to open the DB. The database is now encrypted and Sqlite browser or any sql browser should not be able to open it. If you would like to open then you have to get a browser that can open it buy like SQLiteManager. BTW, the nuget package

    https://www.zetetic.net/sqlcipher/buy/>; @Minafawzy.0454 said:

    @Albert Kay thanks man you save my day , but after add password to my database I cant open it with sqlite browser even I enter correct password xzy1921

    var t = conn.Query<int>("PRAGMA key=xzy1921");

    Hi,

    That is the whole purpose, not to have a third party app to open the DB. The database is now encrypted and Sqlite browser or any sql browser should not be able to open it. If you would like to open the encrypted DB then you have to get a browser that can open it like SQLiteManager.

    https://www.zetetic.net/sqlcipher/buy/

  • AlbertKAlbertK MYMember ✭✭✭

    Hi,

    That is the whole purpose, not to have a third party app to open the DB. The database is now encrypted and Sqlite browser or any sql browser should not be able to open it. If you would like to open the encrypted DB then you have to get a browser that can open it like SQLiteManager.

    https://www.zetetic.net/sqlcipher/buy/

  • TheGreatOneTheGreatOne USMember ✭✭

    Using SQLiteAsyncConnection does not work. Retrieving a record from the table comes out as garbage value. Instead use SQLiteConnection. You can use SQLiteStudio to view your encrypted DB and using the set key to decrypt it.

  • JohnRJohnR USMember

    Is there any way to use SQLiteAsyncConnection with SQLCipher? I was hoping to create some sort of async service in the background.

  • SuchithSuchith INMember ✭✭

    You can checkout the example here implemented using sqlcipher community edition.

  • SteveChadbourneSteveChadbourne USMember ✭✭

    I am using a SQLiteAsyncConnection successfully with SqlCipher

  • TheGreatOneTheGreatOne USMember ✭✭

    @JohnR said:
    Is there any way to use SQLiteAsyncConnection with SQLCipher? I was hoping to create some sort of async service in the background.

    Hi John,
    Were you able to find a solution using SQLiteAsyncConnection?

  • TheGreatOneTheGreatOne USMember ✭✭

    @SteveChadbourne said:
    I am using a SQLiteAsyncConnection successfully with SqlCipher

    How were you able to use SqlCipher in SQLiteAsyncConnection? Did it encrypt the DB?

  • JohnRJohnR USMember

    @TheGreatOne I did not find a way to get SQLiteAsyncConnection to work. However I wrapped it in a task and manually made it async.

  • SteveChadbourneSteveChadbourne USMember ✭✭
    edited November 8

    @TheGreatOne I had a standard SQLite database working with a SQLiteAsyncConnection. I upgraded to SQLCipher using the same SQLiteAsyncConnection and all seemed well. That was when I posted the message. Later that day things went downhill. Encrypted databases I had successfully created and queried would no longer open after closing and re-opening the app. Changing the connection to a SQLiteConnection got everything working again. It's a pain as it blocks the UI. I'll have to wrap stuff in a task like @JohnR at some point.

Sign In or Register to comment.