Comments (28)
Do you plan to merge with master? Would be much easier for us to use it in our Android projects.
from greendao.
For everybody interested in SQLCipher, there's working code in this branch: https://github.com/greenrobot/greenDAO/tree/DbAbstraction
from greendao.
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 :)
from greendao.
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?
from greendao.
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.
from greendao.
Hi @DayS ,
Thanks for sharing your git forked code, I was curious about your implementation. Earlier today I was thinking of manually changing the sqlitedatabase and other database related android objects in my copy of the GreenDAO source code manually . and that was the time i had come across this thread and your implementation of the same thing I was doing. I was curious about the approach. I understand perhaps why you had to use a wrapper to give you that much more flexibility. In my case I have been using greenDAO objects for a while in my application. And there are too many things using them. If I did resort to changing the references I have a feeling I might run into some trouble in one place or another.
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) ?
from greendao.
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 SQLiteOpenHelper
by a wrapper which will do the job by using a common super-class or interface in both Android's and SQLCipher's SQLiteDatabase
classes.
But, as SQLCipher made a total fork of android.database.sqlite
classes with their own package it wasn't possible. This is why I had to add more wrapper and use them everywhere the original ones were used (including in *.ftl files).
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.
from greendao.
Hi,
Thanks for getting back. Your wrapper implementation sure makes it a whole lot easier to deal with it. Cause as I was sitting down to change the reference to all the classes I realized how much there was to be changed manually. But as I had to run it I had to make a few changes in the sense that the DAOmaster class and column-dao files generated would have different method signatures in most cases due to wrapper names. But that was not such a big problem. In any case. Thanks a lot Damian.
from greendao.
I rewrited greenDao to support SQLCipher, but it is not complete(you can use it comfortable yet), https://github.com/ywenblocker/GreenDao-SQLCipher
from greendao.
thanks a lot ywen, I had actually forked daneils work earlier and reworked
it into my project. I liked your approach . its more thorough. thanks
yangwen.
On Tue, Feb 11, 2014 at 1:11 PM, yangwen [email protected] wrote:
I rewrited greenDao to support SQLCipher, but it is not complete(you can
use it comfortable yet), https://github.com/ywenblocker/GreenDao-SQLCipherReply to this email directly or view it on GitHubhttps://github.com//issues/6#issuecomment-34732277
.
from greendao.
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.
from greendao.
Hey,
my project for university is almost finish.
We used greenDAO to setUp our database and now we've got the trouble to encrypt the db.
So I found your solution but I dont get it, what to change.
How can I use your Solution?
Do I have to create new .jar from your fork?
Or what i have to do?
Please help us
from greendao.
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.
I hope this will help you. good luck.
------------------ 原始邮件 ------------------
发件人: "Hukke";
发送时间: 2014年3月25日(星期二) 晚上6:18
收件人: "greenrobot/greenDAO";
抄送: "yang.wen.blocker";
主题: Re: [greenDAO] Support for SQLCipher (#6)
Hey,
my project for university is almost finish.
We used greenDAO to setUp our database and now we've got the trouble to encrypt the db.
So I found your solution but I dont get it, what to change.
How can I use your Solution?
Do I have to create new .jar from your fork?
Or what i have to do?
Please help us
—
Reply to this email directly or view it on GitHub.
from greendao.
Hey,
thank you very much for your fast answer.
So I don't have to recreate my DB-Schema with the Generator.
I only have to change the GreenDao*.jar file in my existing project?
from greendao.
nice!
from greendao.
@ywenblocker Cheers for the changes,
Although it appears something might be amiss.
When using greendao from maven, I get no errors.
However using your fork causes the console to fill up with errors relevant to cursor lifecycle.
Finalizing a Cursor that has not been deactivated or closed. database = /data/data/com._._/databases/app_database, table = null, query = SELECT T.'_id',T.'ID',T.'NAME' FROM LIST T WHERE T.'NAME' LIKE ?
net.sqlcipher.database.DatabaseObjectNotClosedException: Application did not close the cursor or database object that was opened hereReleasing statement in a finalizer. Please ensure that you explicitly call close() on your cursor: SELECT T.'_id',T.'ID',T.'NAME' FROM LIST T WHERE T.'NAME' LIKE ?
net.sqlcipher.database.DatabaseObjectNotClosedException: Application did not close the cursor or database object that was opened here
Any ideas ?
from greendao.
Appreciate that there is an up-to-date branch for this. +1 for support in the main branch.
from greendao.
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:
new de.greenrobot.dao.database.SQLCipherDatabase(db)
Before passing it into DAOMaster. Below is an example
import net.sqlcipher.SQLException;
import net.sqlcipher.database.SQLiteDatabase;
import net.sqlcipher.database.SQLiteOpenHelper;
import de.greenrobot.dao.database.SQLCipherDatabase;
/////////////////////////////////////
SQLiteDatabase.loadLibs(context);
SQLiteOpenHelper helper = new SQLiteOpenHelper(context, "dbname", null, DaoMaster.SCHEMA_VERSION) {
@Override
public void onCreate(SQLiteDatabase sqLiteDatabase) {
DaoMaster.createAllTables(new SQLCipherDatabase(sqLiteDatabase), false);
}
@Override
public void onUpgrade(SQLiteDatabase dbIn, int currentVersion, int lastestVersion) {
SQLCipherDatabase db = new SQLCipherDatabase(dbIn);
// Do what you need to here
}
};
SQLiteDatabase db = helper.getWritableDatabase(key);
/////////////////////////////////////
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
from greendao.
@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.
from greendao.
@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.
from greendao.
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, provided 'com.google.android:android:4.1.1.4'
, but I'm not sure of resolution.
from greendao.
Heres a zip containing the two JARs (Lib/Generator)
https://drive.google.com/file/d/0B0KW2Rx0YisGWHBHd0ZqMXNHYzQ/view?usp=sharing
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.
from greendao.
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.
from greendao.
Not sure to merge this branch into master. There seems a slight overhead produced by the abstraction (~10%).
from greendao.
Can It encrypt the database?and how to solve the problem ...
from greendao.
Can It encrypt the database?and how to solve the problem ...
from greendao.
Can It encrypt the database?and how to solve the problem ...
from greendao.
Has been shipped with version 2.2: http://greenrobot.org/release/greendao-2-2-with-database-encryption/
from greendao.
Related Issues (20)
- incompatible gradle-6.5-bin.zip HOT 1
- Blocker issue in Sonarqube HOT 2
- Openharmony application HOT 1
- 一对多的关系表映射问题 HOT 3
- disk image is malformed (Sqlite code 11 SQLITE_CORRUPT) HOT 1
- How to do data filling, such as populating data from a database in assets into an app HOT 1
- Read this first! Check out our new database
- kotlin version problem HOT 1
- Can I use greenDao in multiple libraries? ------ Look forward to your reply HOT 1
- 什么时候支持协程 HOT 1
- Will a new version be released in the future when a bug occurs in the project? HOT 1
- DaoGenerator.getConfiguration Exception HOT 2
- Lambda 表达式报错 HOT 2
- The project encountered errors after updating Gradle Version 7.6.1 to Gradle Version 8.0+ HOT 40
- when use ’group by‘ ,the result is not expected HOT 1
- Unable to load class 'org.greenrobot.greendao.codemodifier.FormattingOptions'.
- DaoMaster class error HOT 1
- error: cannot find symbol db.execSQL("CREATE TABLE " + constraint + "\ symbol: method makeConcatWithConstants(Lookup,String,MethodType,String) location: interface StringConcatFactory HOT 1
- ... not supported with the configuration cache HOT 1
- net.zetetic:android-database-sqlcipher:3+ update 4+ DaoException HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from greendao.