-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Support for SQLCipher #6
Comments
I had to use SQLCipher and GreenDAO together in one of my project. I just finish to implement the encryption library into greenDAO. The main problem was that SQLCipher use it's own version of SQLite classes instead of extending Android's version... I was thinking about new classes named SQLiteXXXXEncrypted wich extends of the SQLiteXXXX Android class and override all methods to use SQLite's methods. And to use encryption database, a new class should have mad to work great. But SQLiteDatabase has a private constructor, so this solution is not possible. However, I choose an other option : wrappers. The idea is almost the same : create new classes names SQLiteXXXXWrapper wich don't extends any other class. But the implementation of each method will just call SQLCipher's or Android's version according to the encryption configuration. One of the side effect was to change the reference to SQLiteXXXX classes everywhere in greenDAO. Exemple (in SQLiteDatabaseWrapper) : public void beginTransaction() {
if (isCypheredDb())
sqlCypheredDatabase.beginTransaction();
else
sqliteDatabase.beginTransaction();
} I'll made a pull request soon for interested person :) |
Would be great if SQLCipher-Support was integrated in git-Version :) Or is can use DayS-Fork and then simple update with master Version without any problem? |
Great work! I am trying to use SQLCipher and GreenDAO in my android applciation. Can you I fork your android project ? Waiting for your positive reply. Thanks and advance. |
Hi @DayS , That being said did you have to also modify the source of the standard DAO generator you had to use? Did you have to modify the template(*.ftl file) ? |
Hi, In my PR I wanted to allow the developer to choose between encrypted database and non-encrypted database. The main idea was to simply replace the entry point So, if you want to change database related object and the new objects have something in common with theses original classes, you should be able to do it easily. I Hope this help. |
Hi, |
I rewrited greenDao to support SQLCipher, but it is not complete(you can use it comfortable yet), https://github.com/ywenblocker/GreenDao-SQLCipher |
thanks a lot ywen, I had actually forked daneils work earlier and reworked On Tue, Feb 11, 2014 at 1:11 PM, yangwen notifications@github.com wrote:
|
hi there, I have rewrite greenDao to support SQLCipher completely, you can use it from here:https://github.com/ywenblocker/GreenDao-SQLCipher. I wish greenDao can update latest greenDao project code to Let GreenDao-SQLCipher update to the latest. |
Hey, How can I use your Solution? |
hi, there: you don't need to fork my code,you can just download the DaoExample, read the demo code, replace the old greenDao_.jar with the new greenDao_.jar that I had put it on the libs dir on GitHub, it's easy to encrypt the db. ------------------ 原始邮件 ------------------ Hey, How can I use your Solution? — |
Hey, |
nice! |
@ywenblocker Cheers for the changes, When using greendao from maven, I get no errors.
Any ideas ? |
For everybody interested in SQLCipher, there's working code in this branch: https://github.com/greenrobot/greenDAO/tree/DbAbstraction |
Do you plan to merge with master? Would be much easier for us to use it in our Android projects. |
Appreciate that there is an up-to-date branch for this. +1 for support in the main branch. |
For those attempting to implement this, You can no longer use the DaoMaster.OpenHelper. As it provides no way to pass a key in. Instead if your using SQLCipher you have to use the SQLCipher OpenHelper and methods etc. Then wrap the SQLCipher DB created by the openHelper in a:
Before passing it into DAOMaster. Below is an example
Great work, it would be good to get this into master. You won't believe the things I had to do to get SQLCipher with GreenDAO working for production and robolectric unit tests, this feature has removed the nastiness required. Was about to jump ship to Realm as soon as they got Unit Tests working but this change has significantly reduced the need to jump ship. Cheers |
@McPo Can you give some more detailed instructions about how to make the changes you are talking about? I just tried to generate dao using the DbAbstraction branch but I'm getting a bunch of errors in the generated code. |
@marvinmarnold Make sure your using the new DAOGenerator JAR as well and that you've regenerated your DAOs. If you intend to use SQLCipher it is not integrated with this branch, its only supported (You still need to get SQLCipher from https://www.zetetic.net/sqlcipher/), although that shouldn't cause any errors in the DAOS. Im not sure how much more detail can be given, the code above should be good to copy and paste (I might get around to converting the sample app, but I wont get round to it for some time). Id also make sure your using the right imports. If you post some of the errors that your given, I might be able to assist more, although Im not sure if this is the right place for it. |
Thanks @McPo . I think you are right that my issue is off topic. After digging deeper, I think the problem is trying to build the project from source* as I'm not using JARs. Is there somewhere I can find up-to-date JARs for this branch? * Android dependencies aren't loading. Probably related to DaoCore/gradle.build#L31, |
Heres a zip containing the two JARs (Lib/Generator) Id advise you to make an issue on StackOverflow regarding your other issue, but it looks like you need to install Google/Support repository from the SDK manager. |
Awesome @McPo, you are the man. I got a working demo up here. I still need to do some sanity checks and make sure that the DB is actually being encrypted but its all compiling fine now thanks to your JARs. I opened up a StackOverflow question regarding the other issue. |
Not sure to merge this branch into master. There seems a slight overhead produced by the abstraction (~10%). |
Can It encrypt the database?and how to solve the problem ... |
2 similar comments
Can It encrypt the database?and how to solve the problem ... |
Can It encrypt the database?and how to solve the problem ... |
Has been shipped with version 2.2: http://greenrobot.org/release/greendao-2-2-with-database-encryption/ |
SQLCipher has its own native libs and classes.
http://sqlcipher.net/sqlcipher-for-android/
The text was updated successfully, but these errors were encountered: