davidmartos96 / sqflite_sqlcipher

SQLite flutter plugin
BSD 2-Clause "Simplified" License
99 stars 44 forks source link

Hai, I have built the SQLCipher source in Windows. But please let me know how to encrypt an already existing database using it. #75

Closed Shruthi125 closed 1 year ago

davidmartos96 commented 1 year ago

This script encrypts a database passed by parameter https://github.com/davidmartos96/sqflite_sqlcipher/issues/74#issuecomment-1639483647

Then it copies it to the assets folder in your app

davidmartos96 commented 1 year ago

@Shruthi125 to confirm that you correctly installed SQLCipher on your Windows you can do the following.

Open a cmd and then do the following

> sqlcipher  # This would be the executable that you compiled. Maybe it's called simply sqlite when building, I'm not 100% sure
> PRAGMA cipher_version();

It should output something along the lines of SQLCipher Community Version 4.x

Shruthi125 commented 1 year ago

Yes, I got that--- sqlite> PRAGMA cipher_version; 4.5.4 community.
What are the commands to be run on the prompt to encrypt an already created db with multiple tables in it?

davidmartos96 commented 1 year ago

@Shruthi125 Here https://github.com/davidmartos96/sqflite_sqlcipher/issues/74#issuecomment-1639483647

Shruthi125 commented 1 year ago

This script encrypts a database passed by parameter #74 (comment)

Then it copies it to the assets folder in your app

Please let me know about the prompt run commands other than git bash script

davidmartos96 commented 1 year ago

@Shruthi125 While inside a SQLCipher session with the regular sqlite database opened, you can run this.

ATTACH DATABASE 'encrypted.db' AS encrypted KEY '123456ABC'; SELECT sqlcipher_export('encrypted'); DETACH DATABASE encrypted;

It will create a new file named encrypted.db

Shruthi125 commented 1 year ago

Ohk. Thank you! Let me check if its working.

Shruthi125 commented 1 year ago

@Shruthi125 to confirm that you correctly installed SQLCipher on your Windows you can do the following.

Open a cmd and then do the following

> sqlcipher  # This would be the executable that you compiled. Maybe it's called simply sqlite when building, I'm not 100% sure
> PRAGMA cipher_version();

It should output something along the lines of SQLCipher Community Version 4.x

The .exe file that got installed is sqlite3. Is there any other exe file to be built?

davidmartos96 commented 1 year ago

@Shruthi125 I don't think so. You could rename it to sqlcipher.exe or leave it as is. Sqlcipher is an extension on top of regular Sqlite, you can use it like a regular Sqlite by not providing a password.

davidmartos96 commented 1 year ago

Closing, as this is not exactly an issue. You can open a discussion instead.