Feb 13, 2012 Replies: 163 Edit: this library isn't compatible with the 16KB page size requirement. Don't use it. SQLCipher is an open source project that extends SQLite and adds full database encryption. License: https://www.zetetic.net/sqlcipher/open-source/ B4A SQLCipher is a special subtype of SQL object. There is almost no need to change any code in order to switch from regular SQL to SQLCipher. The only difference between SQL API and SQLCipher API is the Initialize method. SQLCipher.Initialize expects two additional values: Password and a second parameter that is not used (it was used in the past). Password is the database password. You can pass an empty string if there is no password. Note that it is not possible to change the password (or set a new password) to an existing database. Code changes required to convert from SQL to SQLCipher - Declare the SQL object as SQLCipher. - Change the initialize code to: Code: Copy SQL1.Initialize(File.DirRootExternal, "1.db", True, DB_PASSWORD, "") V1.70 Based on SQLCipher v4.5.4: https://www.zetetic.net/blog/2023/04/27/sqlcipher-4.5.4-release/ V1.60 Based on SQLCipher v4.00: https://www.zetetic.net/blog/2018/11/30/sqlcipher-400-release/ Includes 64 bit binaries and emulator binaries. Requires B4A v8+. Library is attached. Not compatible by default with databases created with older versions. See this link: https://www.zetetic.net/blog/2018/11/30/sqlcipher-400-release/#compatibility V1.50 Based on SQLCipher v3.59 Supports targetSdkVersion 26. The icu.zip file is no longer required. You can delete it from the Files folder. It is no longer required to disable the debugger virtual assets feature. Remove this line: #DebuggerForceStandardAssets: True Old version: www.b4x.com/android/files/SQLCipher150.zip Depends on: https://repo1.maven.org/maven2/net/...er/4.5.4/android-database-sqlcipher-4.5.4.aar You should download and copy it to the additional libraries folder. Attachments SQLCipher.zip SQLCipher.zip 37.2 KB · Views: 1,303 Last edited: Jul 20, 2025 Click to expand...
Edit: this library isn't compatible with the 16KB page size requirement. Don't use it. SQLCipher is an open source project that extends SQLite and adds full database encryption. License: https://www.zetetic.net/sqlcipher/open-source/ B4A SQLCipher is a special subtype of SQL object. There is almost no need to change any code in order to switch from regular SQL to SQLCipher. The only difference between SQL API and SQLCipher API is the Initialize method. SQLCipher.Initialize expects two additional values: Password and a second parameter that is not used (it was used in the past). Password is the database password. You can pass an empty string if there is no password. Note that it is not possible to change the password (or set a new password) to an existing database. Code changes required to convert from SQL to SQLCipher - Declare the SQL object as SQLCipher. - Change the initialize code to: Code: Copy SQL1.Initialize(File.DirRootExternal, "1.db", True, DB_PASSWORD, "") V1.70 Based on SQLCipher v4.5.4: https://www.zetetic.net/blog/2023/04/27/sqlcipher-4.5.4-release/ V1.60 Based on SQLCipher v4.00: https://www.zetetic.net/blog/2018/11/30/sqlcipher-400-release/ Includes 64 bit binaries and emulator binaries. Requires B4A v8+. Library is attached. Not compatible by default with databases created with older versions. See this link: https://www.zetetic.net/blog/2018/11/30/sqlcipher-400-release/#compatibility V1.50 Based on SQLCipher v3.59 Supports targetSdkVersion 26. The icu.zip file is no longer required. You can delete it from the Files folder. It is no longer required to disable the debugger virtual assets feature. Remove this line: #DebuggerForceStandardAssets: True Old version: www.b4x.com/android/files/SQLCipher150.zip Depends on: https://repo1.maven.org/maven2/net/...er/4.5.4/android-database-sqlcipher-4.5.4.aar You should download and copy it to the additional libraries folder.
S susu Well-Known Member Licensed User Longtime User Feb 13, 2012 #2 Thank you Erel. I wished for this library.
S Sanxion Active Member Licensed User Longtime User Feb 13, 2012 #3 SQLite db created outside of the application? This is great news, however I do have a question: How would I encrypt/set a password for a SQLite database that has been created/populated outside of a B4A application which is then to be used in the application?
SQLite db created outside of the application? This is great news, however I do have a question: How would I encrypt/set a password for a SQLite database that has been created/populated outside of a B4A application which is then to be used in the application?
Erel B4X founder Staff member Licensed User Longtime User Feb 14, 2012 #5 How would I encrypt/set a password for a SQLite database that has been created/populated outside of a B4A application which is then to be used in the application? Click to expand... You have two options: - Use the desktop version of SQLCipher. It may require purchasing a license. - Create a program that reads the data from the existing databases and writes it to a password protected database.
How would I encrypt/set a password for a SQLite database that has been created/populated outside of a B4A application which is then to be used in the application? Click to expand... You have two options: - Use the desktop version of SQLCipher. It may require purchasing a license. - Create a program that reads the data from the existing databases and writes it to a password protected database.
S Sanxion Active Member Licensed User Longtime User Feb 14, 2012 #6 Thanks Erel... How is a password protected database created in the first instance? I have been using SQLite Database Browser to create and subsequently populate my database.
Thanks Erel... How is a password protected database created in the first instance? I have been using SQLite Database Browser to create and subsequently populate my database.
Erel B4X founder Staff member Licensed User Longtime User Feb 15, 2012 #7 You should create it with a tool that supports SQLCipher. You can also build a small Android program that converts your existing database to an encrypted database.
You should create it with a tool that supports SQLCipher. You can also build a small Android program that converts your existing database to an encrypted database.
S Sanxion Active Member Licensed User Longtime User Feb 15, 2012 #8 For those who are looking for an application that will enable the setting of a password on an SQLite database... I have discovered Navicat supports this functionality.
For those who are looking for an application that will enable the setting of a password on an SQLite database... I have discovered Navicat supports this functionality.
Erel B4X founder Staff member Licensed User Longtime User Feb 16, 2012 #9 Are you sure that they support SQLCipher encryption? There are several encryption modules.
alfcen Well-Known Member Licensed User Longtime User Feb 18, 2012 #10 If I am not mistaken this library does not perform encryption but addresses databases that have been previously ciphered using SQLCipher or similar tools?
If I am not mistaken this library does not perform encryption but addresses databases that have been previously ciphered using SQLCipher or similar tools?
Erel B4X founder Staff member Licensed User Longtime User Feb 18, 2012 #11 This library does allow you to create newly encrypted databases. The Android version of SQLCipher currently doesn't support encrypting existing databases.
This library does allow you to create newly encrypted databases. The Android version of SQLCipher currently doesn't support encrypting existing databases.
NJDude Expert Licensed User Longtime User Feb 18, 2012 #12 Just to clarify, let's say, I create a DB using an SQLite editor, no data, just an empty DB, can I encrypt it using the new library for B4A?
Just to clarify, let's say, I create a DB using an SQLite editor, no data, just an empty DB, can I encrypt it using the new library for B4A?
Erel B4X founder Staff member Licensed User Longtime User Feb 18, 2012 #13 I'm not sure about an empty database. However if there is at least one table then you will not be able to encrypt it.
I'm not sure about an empty database. However if there is at least one table then you will not be able to encrypt it.
P psdos Active Member Licensed User Longtime User Feb 19, 2012 #14 I am waiting update of this library for full support encrypted, read and write in db with password, but thanks for this, is a started. Thanks.
I am waiting update of this library for full support encrypted, read and write in db with password, but thanks for this, is a started. Thanks.
Erel B4X founder Staff member Licensed User Longtime User Feb 20, 2012 #15 This library does fully support reading and writing encrypted databases.
Taha Member Licensed User Longtime User Feb 26, 2012 #16 Spent 2 days looking on how to encrypt the SQLite database - couldn't find any clear explanation or application. Can't understand why do we need this library then? Isn't there any other ways for encryption?
Spent 2 days looking on how to encrypt the SQLite database - couldn't find any clear explanation or application. Can't understand why do we need this library then? Isn't there any other ways for encryption?
Erel B4X founder Staff member Licensed User Longtime User Feb 26, 2012 #17 Not sure that I understand your question. Android internal SQLite engine doesn't support encryption. This library includes an engine that does support encryption. You can create and access encrypted databases with this library. SQLCipher doesn't support encryption of existing non-encrypted databases. You can however create a small program that will read the data from your existing database and then add it to the encrypted database. From then on you can work with the encrypted database.
Not sure that I understand your question. Android internal SQLite engine doesn't support encryption. This library includes an engine that does support encryption. You can create and access encrypted databases with this library. SQLCipher doesn't support encryption of existing non-encrypted databases. You can however create a small program that will read the data from your existing database and then add it to the encrypted database. From then on you can work with the encrypted database.
S susu Well-Known Member Licensed User Longtime User Feb 26, 2012 #18 Erel said: You can however create a small program that will read the data from your existing database and then add it to the encrypted database. From then on you can work with the encrypted database. Click to expand... Could you please give us some codes of that "small program" ?
Erel said: You can however create a small program that will read the data from your existing database and then add it to the encrypted database. From then on you can work with the encrypted database. Click to expand... Could you please give us some codes of that "small program" ?
Erel B4X founder Staff member Licensed User Longtime User Feb 26, 2012 #19 A general solution is much more complicated than a specific solution. You should use two SQL objects. One with the old database and the second with the new one. Go over the data and insert it to the new database.
A general solution is much more complicated than a specific solution. You should use two SQL objects. One with the old database and the second with the new one. Go over the data and insert it to the new database.
S susu Well-Known Member Licensed User Longtime User Feb 26, 2012 #20 Step by step: - Open "normal" database1. - Create new database2. - Encrypt database1 and write into database2. - Delete database1. - Only encrypted database2 left. Is it right?
Step by step: - Open "normal" database1. - Create new database2. - Encrypt database1 and write into database2. - Delete database1. - Only encrypted database2 left. Is it right?