如何使用sql cipher加密数据库 [英] how to encrypt an database using sql cipher

查看:210
本文介绍了如何使用sql cipher加密数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用sqlcipher加密数据库。

I want to encrypt an database using sqlcipher.

我已经完成了集成os openssl和sqlcipher集成,并且构建工作非常完美。

I have done with the integration os openssl and sqlcipher integration and the build works perfect.

但我的问题是我无法加密我的数据库。我不知道如何使用sql cipher执行该活动或方法来加密数据库。

But my issue is I am not able to encrypt my database. I don't know how to perform that activity or method to encrypt a database using sql cipher.

我读了 SQL Cipher 但我无法理解同样的过程。我尝试了他们提供但不能正常工作的代码。

I read on the SQL Cipher but I am not able to understand the same process. I tried the code that is provided by them but not working .

编辑:任何人都可以告诉我如何设置相同的PRAGMA密钥然后如何从加密开始?因为我的加密只剩下这部分才能完成。

请帮我解决这个问题。

提前致谢

推荐答案

使用SQLCipher确保您拥有一个全新的SQLite数据库。尝试使用密钥对数据库进行编译,因为某些原因因为某些原因已经有数据只是尝试解密它。

With SQLCipher make sure you have a brand new SQLite database. Trying to pragma the database with a key while it already has data for some reason just tries to decrypt it.

以下是使用现有的SQLite数据库。在此示例中,encrypted.db是您创建的全新数据库和pragma。

Here is some additional information on working with an existing SQLite database. In this example encrypted.db is that brand new database you create and pragma.

ATTACH DATABASE 'encrypted.db' AS encrypted KEY 'secret'; -- create a new encrypted database
CREATE TABLE encrypted.t1(a,b); -- recreate the schema in the new database (you can inspect all objects using SELECT * FROM sqlite_master)
INSERT INTO encrypted.t1 SELECT * FROM t1; -- copy data from the existing tables to the new tables in the encrypted database
DETACH DATABASE encrypted;

这篇关于如何使用sql cipher加密数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆