标签: sqlcipher

文件已加密或不是数据库(Exception net.sqlcipher.database.SQLiteException)

我正在尝试使用sqlcipher lib从现有数据库加密我的数据库,但在访问旧数据库(即打开数据库)时会出现以下异常:

 02-27 13:12:21.231: E/AndroidRuntime(14687): FATAL EXCEPTION: main
 02-27 13:12:21.231: E/AndroidRuntime(14687): java.lang.RuntimeException: Unable to start activity ComponentInfo{net.sqlcipher/example.SQLDemoActivity}: net.sqlcipher.database.SQLiteException: file is encrypted or is not a database
 02-27 13:12:21.231: E/AndroidRuntime(14687):   at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2184)
 02-27 13:12:21.231: E/AndroidRuntime(14687):   at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2211)
 02-27 13:12:21.231: E/AndroidRuntime(14687):   at android.app.ActivityThread.access$600(ActivityThread.java:149)
 02-27 13:12:21.231: E/AndroidRuntime(14687):   at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1300)
 02-27 13:12:21.231: E/AndroidRuntime(14687):   at android.os.Handler.dispatchMessage(Handler.java:99)
 02-27 13:12:21.231: E/AndroidRuntime(14687):   at android.os.Looper.loop(Looper.java:153)
 02-27 13:12:21.231: E/AndroidRuntime(14687):   at android.app.ActivityThread.main(ActivityThread.java:4987)
 02-27 13:12:21.231: E/AndroidRuntime(14687):   at java.lang.reflect.Method.invokeNative(Native Method)
 02-27 13:12:21.231: E/AndroidRuntime(14687):   at java.lang.reflect.Method.invoke(Method.java:511)
 02-27 13:12:21.231: E/AndroidRuntime(14687):   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:821)
 02-27 13:12:21.231: E/AndroidRuntime(14687): …
Run Code Online (Sandbox Code Playgroud)

database sqlite java-native-interface android sqlcipher

3
推荐指数
1
解决办法
9319
查看次数

如何加密/解密我的CoreData(sqlite)?我可以使用SQLCipher吗?

  1. 如果我想保护我的应用程序数据库,我该怎么办?
  2. 使用SQLCipher需要了解什么?

sqlite encryption core-data ios sqlcipher

3
推荐指数
1
解决办法
3413
查看次数

使用SQLCipher和Crashlytics for x86_64和arm84_v8a时,Android应用程序崩溃与UnsatisfiedLinkError

我创建了一个非常小的应用程序,只显示"Hello World".主要活动调用加载SQLCipher库.

package companydomain.myapplication;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import net.sqlcipher.database.SQLiteDatabase;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        SQLiteDatabase.loadLibs(this);            // loading the SQLCipher libraries
    }
}
Run Code Online (Sandbox Code Playgroud)


build.gradle(module:app)是:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 25
    buildToolsVersion '25.0.0'

    defaultConfig {
        minSdkVersion 16
        targetSdkVersion 25
    }
    return void
}

dependencies {
    compile 'com.android.support:appcompat-v7:25.0.1'
    compile 'net.zetetic:android-database-sqlcipher:3.5.4@aar'
}
Run Code Online (Sandbox Code Playgroud)


此应用程序按预期工作.
但是,当我将Crashlytics添加到build.gradle时:

buildscript {
    repositories {
        maven { url 'https://maven.fabric.io/public' }
    }
    dependencies {
        classpath 'io.fabric.tools:gradle:1.+'
    }
}

apply plugin: 'com.android.application' …
Run Code Online (Sandbox Code Playgroud)

android sqlcipher unsatisfiedlinkerror crashlytics

3
推荐指数
1
解决办法
1525
查看次数

如何在.Net中使用SQLCipher

我想用C#(winform)读取一个SQLCipher数据库,找到一个开源项目SQLitePCL,但是还没有找到这个使用的例子,而且文档也不是很多。有朋友用过这个东西吗,能提供一些例子来帮助我吗?

谢谢你!

c# sqlite encryption sqlcipher

3
推荐指数
1
解决办法
1万
查看次数

如何在Assets文件夹中保护我的数据库sqlite(通过加密)?

我有过逆向工程的经验,人们可以在android中安静地访问你的数据库.我想知道有什么方法我可以在创建时只加密我的数据库(不会混淆整个apk),然后在RunTime期间我会使用我的数据库.

我对数据库知之甚少,所以任何建议都可以像保护我在资产文件夹中的数据库一样.

sqlite android sqlcipher

2
推荐指数
1
解决办法
2677
查看次数

SQLCipher Loadlibs 和数据库密码更改

SQLCipher 网站提到

"使用 SQLiteDatabase.loadLibs(this) 在 onCreate() 中初始化数据库;//首先使用上下文初始化数据库库"

  1. 我在我的第一个活动中只调用了一次这个 loadlibs(似乎正在工作)。我想确保不需要为可能访问数据库的每个活动调用此函数。这样对吗?

  2. 如何更改数据库密码?我试过重新加密,但这不起作用。它仍然需要旧密码。

任何帮助,将不胜感激。

谢谢你。

database sqlite android sqlcipher

2
推荐指数
1
解决办法
3107
查看次数

将SqlCipher与Android应用程序集成(在Windows上)

我不太了解以下文档:http://sqlcipher.net/sqlcipher-for-android/

我应该做什么,步骤是什么?看起来这些说明只属于MAC用户,我的操作系统是Windows 7.

谁能告诉我该怎么办?二进制文件包含"libs"和"assets"文件夹.如何将这些集成到我现有的应用程序中?

java sql eclipse android sqlcipher

2
推荐指数
1
解决办法
3292
查看次数

sqlcipher - 更改数据库密码失败

对于这个应用程序,我有一个使用sqlcipher的数据库,该密码保护.

我有一个活动,允许我使用以下代码更改密码:

SQLiteDatabase database = SQLiteDatabase.openDatabase(getDatabasePath("db").getPath() , oldPass, null,0) ;
database.rawExecSQL("PRAGMA rekey = '"+newPass+"';");
database.close();
Run Code Online (Sandbox Code Playgroud)

执行前一段代码后,应用程序恢复正常操作,同时尝试再次访问数据库,我得到:

10-21 16:40:28.961  26635-26635/com.example            E/Database: CREATE TABLE android_metadata failed
10-21 16:40:28.981  26635-26635/com.example            E/Database: Failed to setLocale() when constructing, closing the database
        net.sqlcipher.database.SQLiteException: file is encrypted or is not a database
        at net.sqlcipher.database.SQLiteDatabase.native_setLocale(Native Method)
        at net.sqlcipher.database.SQLiteDatabase.setLocale(SQLiteDatabase.java:2101)
        at net.sqlcipher.database.SQLiteDatabase.<init>(SQLiteDatabase.java:1967)
        at net.sqlcipher.database.SQLiteDatabase.openDatabase(SQLiteDatabase.java:900)
        at net.sqlcipher.database.SQLiteDatabase.openOrCreateDatabase(SQLiteDatabase.java:943)
        at net.sqlcipher.database.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:107)
Run Code Online (Sandbox Code Playgroud)

其次是:

Caused by: net.sqlcipher.database.SQLiteException: file is encrypted or is not a database
    at net.sqlcipher.database.SQLiteDatabase.native_setLocale(Native Method)
    at net.sqlcipher.database.SQLiteDatabase.setLocale(SQLiteDatabase.java:2101)
    at net.sqlcipher.database.SQLiteDatabase.<init>(SQLiteDatabase.java:1967)
    at net.sqlcipher.database.SQLiteDatabase.openDatabase(SQLiteDatabase.java:900)
    at …
Run Code Online (Sandbox Code Playgroud)

sqlite android sqlcipher

2
推荐指数
1
解决办法
3303
查看次数

Sqlcipher __ CREATE TABLE android_metadata失败

我正在尝试在我的Android应用程序中附加现有的sqlcipher数据库(加密),但在我的目录中复制后,无法使用"SQLiteDatabase.openDatabase(...)"打开它

我在普通的sqlite中尝试了代码并且它可以正常工作,但是当我使用sqlcipher API时,我收到了此错误消息

 //CREATE TABLE android_metadata failed
 //Failed to setLocale() when constructing, closing the database
 // net.sqlcipher.database.SQLiteException: file is encrypted or is not a database
Run Code Online (Sandbox Code Playgroud)

我在SQLiteOpenHelper类中使用了以下代码:

      if(!dbExist1)
      {

            this.getWritableDatabase(password);
            this.openDatabase();
            try
            {
                  this.close();    
                  copyDataBase();
            }
            catch (IOException e)
            {

                  throw new Error("Error copying database");
            }
      }


        public SQLiteDatabase openDatabase() throws SQLException {
    String DBPath = DATABASE_PATH + DATABASE_NAME;

    myDataBase = SQLiteDatabase.openDatabase(DBPath, password, null,
            SQLiteDatabase.NO_LOCALIZED_COLLATORS);
    return myDataBase;
}
Run Code Online (Sandbox Code Playgroud)

我在Activity Class中使用了以下代码:

  SQLiteDatabase.loadLibs(this);
 DataBaseHelper myDbHelper ;
      myDbHelper = new DataBaseHelper(this);
  SQLiteDatabase db=myDbHelper.openDatabase();
Run Code Online (Sandbox Code Playgroud)

我试图使用 …

sqlite android sqlcipher

2
推荐指数
1
解决办法
4111
查看次数

是否需要SQLCipher?

现在,对于iOS 8.3及更高版本,iOS不允许应用程序文件夹访问任何不支持iTunes文件共享的应用程序,是否真的有必要使用SQLCipher或者对数据进行任何加密,考虑到性能影响SQLCipher有.此外,距离iOS 10仅几个月之后,我们很有可能在我们的应用程序中完全放弃iOS 8支持.

ios sqlcipher ios8 ios9

2
推荐指数
1
解决办法
171
查看次数