搜索
查看
编辑修改
首页
UNITY
NODEJS
PYTHON
AI
GIT
PHP
GO
CEF3
JAVA
HTML
CSS
搜索
小丑西瓜9
这个屌丝很懒,什么也没留下!
关注作者
热门标签
jquery
HTML
CSS
PHP
ASP
PYTHON
GO
AI
C
C++
C#
PHOTOSHOP
UNITY
iOS
android
vue
xml
爬虫
SEO
LINUX
WINDOWS
JAVA
MFC
CEF3
CAD
NODEJS
GIT
Pyppeteer
article
热门文章
1
深入探索 Apache Flink:流式处理框架的奥秘
2
基于微信小程序的宠物寄养小程序,附源码
3
Gitea 的简单介绍(全)
4
道友自诉:入职中软一个月(外包华为)就离职了!
5
数字ic设计——UART_uart设计
6
干货||常见软件测试管理工具_常用的软件测试过程管理工具
7
windows 10 卸载 Microsoft 安全中心工具_win10卸载安全中心软件
8
【MongoDB】数据的自动过期,TTL索引
9
Flutter: won‘t run without google play services, which are not supported by your device 解决办法
10
Flink窗口机制
当前位置:
article
> 正文
Linux安装编译SQLCipher,对sqlite数据库加密、解密、修改、去掉密码操作_cflags="-dsqlite_has_codec
作者:小丑西瓜9 | 2024-04-26 18:02:57
赞
踩
cflags="-dsqlite_has_codec
本文主要是自己在实际用的过程记录,如发现理解错误,欢迎指正。
1
https://github.com/sqlcipher/sqlcipher
下载源代码
2 # ./configure --enable-tempstore=yes CFLAGS="-DSQLITE_HAS_CODEC"
3 # make
make: tclsh: Command not found
make: *** [fts5.c] Error 127
make: *** Waiting for unfinished jobs....
#
./configure --enable-tempstore=yes CFLAGS="-DSQLITE_HAS_CODEC" --disable-tcl
#
make -j 16
cat parse.h /home/work/guoli/sqlcipher-master/src/vdbe.c | tclsh /home/work/guoli/sqlcipher-master/tool/mkopcodeh.tcl >opcodes.h
/bin/sh: tclsh: command not found
make: *** [opcodes.h] Error 127
--------------------------------------------------------------------------------
4 安装tcl
http://www.tcl.tk/software/tcltk/
# tar -xvzf tcl8.6.8-src.tar.gz
#cd tcl8.6.8/unix
#./configure --prefix=/user/local/tcl
# make
#sudo make install
# sudo ln -s /user/local/tcl/bin/tclsh8.6 /bin/tclsh
--------------------------------------------------------------------------------
重复步骤2
报错:
sqlite3.c:16702:3: error: unknown type name ‘sqlite3_mutex’
5 怀疑需要安装 sqlite
http://124.205.69.135/files/11450000061AF698/www.sqlite.org/2017/sqlite-autoconf-3210000.tar.gz
#tar -xvxf sqlite-autoconf-3210000.tar.gz
#cd sqlite-autoconf-3210000/
#./configure
#make
#sudo make install
--------------------------------------------------------------------------------
重复步骤2
编译通过
-------------------------------- 测试 --------------------------------------
加密已有的数据库(参考
http://blog.csdn.net/sskicgah/article/details/37502433
)
1.先用sqlite打开db文件
sqlite3 test.db
2.把数据导成sql格式
sqlite> .output test.sql
sqlite> .dump
sqlite> .exit
3.加密
//加密的过程是生成了一个新的有密码的数据库
./sqlcipher test2.db #创建一个新的db文件
sqlite> PRAGMA key = 'test'; #设置密码
sqlite> .read test.sql #导入数据
sqlite> .exit #退出
把加密过的文件放在Windows 下用navicat premium 直接查看,加密成功。
但是用sqlcipher.exe输入设置的密码,确不能打开
经检查:sqlcipher.exe 是2.1版本的。加密用的是基于3.20.1版本,不同的版本生成的db文件可能不兼容
4. 解密
#./sqlcipher test2.db
sqlite> PRAGMA KEY='test';
//需
先输密码解密再进行其他操作
sqlite> .schema
CREATE TABLE xxxx ... ...
# ./sqlcipher test2.db
sqlite> .schema
Error: file is not a database
(还以为把密码设置成空,就能把密码抹去,原来不是这么一回事)
#./sqlcipher test2.db
sqlite> PRAGMA key = 'test';
//去掉密码的过程是生成了一个新的没有密码的数据库
sqlite> ATTACH DATABASE 'text.db' AS plaintext KEY '';
sqlite> SELECT sqlcipher_export('plaintext');
sqlite> DETACH DATABASE plaintext;
sqlite> .exit
#./sqlcipher text.db //查看新库
sqlite> .schema
CREATE TABLE xxxx
5 修改密码
# ./sqlcipher test2.db
sqlite> PRAGMA KEY='test';
sqlite> PRAGMA rekey = 'newkey';
sqlite> .exit
借鉴了很多网友的帖子,多谢~
--------------------------------------------------------------------------------
其他
报错:
./.libs/libsqlcipher.so: undefined reference to `HMAC_CTX_new'
./.libs/libsqlcipher.so: undefined reference to `HMAC_CTX_free'
collect2: error: ld returned 1 exit status
make: *** [sqlcipher] Error 1
交叉编译sqlcipher
https://www.cnblogs.com/bbqzsl/p/7736060.html
--------------------------------------------------------------------------------
SQLCipher主要API
(
https://www.zetetic.net/sqlcipher/sqlcipher-api/
)
PRAGMA key
Example 1: Passphrase with Key Derivation
sqlite> PRAGMAkey = 'passphrase';
Example 2: Raw Key Data (Without KeyDerivation)
sqlite> PRAGMA key = "x'2DD29CA851E7B56E4697B0E1F08507293D761A05CE4D1B628663F411A8086D99'";
PRAGMA cipher
sqlite> PRAGMA key = 'blue valentines';
sqlite> PRAGMA cipher = 'aes-256-cfb';
PRAGMA kdf_iter
sqlite> PRAGMA key = 'blue valentines';
sqlite> PRAGMA kdf_iter = '10000';
PRAGMA cipher_default_kdf_iter
./sqlcipher sqlcipher2.0.db
sqlite> PRAGMA cipher_default_kdf_iter = 4000;
sqlite> PRAGMA key = 's3cr37';
PRAGMA cipher_page_size
sqlite> PRAGMA KEY = 'testkey';
sqlite> PRAGMA cipher_page_size = 4096;
PRAGMA cipher_default_page_size
$ ./sqlcipher foo.db
sqlite> PRAGMA key = 'foo';
sqlite> PRAGMA cipher_page_size = 4096;
sqlite> CREATE TABLE t1(a,b);
sqlite> INSERT INTO t1(a,b) values('one for the money', 'two for the show');
sqlite> .q
$ ./sqlcipher bar.db
sqlite> PRAGMA cipher_default_page_size = 4096;
sqlite> PRAGMA key = 'bar';
sqlite> ATTACH DATABASE 'foo.db' as foo KEY 'foo';
sqlite> SELECT count(*) FROM foo.t1;
PRAGMA rekey
sqlite> PRAGMA key = 'old passphrase';
sqlite> PRAGMA rekey = 'new passphrase';
PRAGMA cipher_use_hmac
sqlite> PRAGMA key = 'blue valentines';
sqlite> PRAGMA cipher_use_hmac = OFF;
PRAGMA cipher_default_use_hmac
./sqlcipher sqlcipher2.0.db
sqlite> PRAGMA key = 's3cr37'; -- opens using default setting, with HMAC on
sqlite> PRAGMA cipher_default_use_hmac = OFF;
sqlite> ATTACH DATABASE '1.1.x.db' AS remote key 's3cr37'; -- next open operation, the default for HMAC is off, and this database
ATTACH
Example 1: Attach an Encrypted Database to aPlaintext Database
$ ./sqlcipher plaintext.db
sqlite> ATTACH DATABASE 'encrypted.db' AS encrypted KEY 'testkey';
Example 2: Attach an Encrypted Database usinga Hex Key
$ ./sqlcipher plaintext.db
sqlite> ATTACH DATABASE 'test2.db' AS db2 KEY "x'10483C6EB40B6C31A448C22A66DED3B5E5E8D5119CAC8327B655C8B5C4836481'";
Example 3: Attach an Plaintext Database to anEncrypted Database
$ ./sqlcipher encrypted.db
sqlite> ATTACH DATABASE 'plaintext.db' AS plaintext KEY ''; -- empty key will disable encryption
sqlcipher_export()
Example 1: Encrypt a Plaintext Database
$ ./sqlcipher plaintext.db
sqlite> ATTACH DATABASE 'encrypted.db' AS encrypted KEY 'testkey';
sqlite> SELECT sqlcipher_export('encrypted');
sqlite
> DETACH DATABASE encrypted;
Example 2: Decrypt a SQLCipher database to aPlaintext Database
$ ./sqlcipher encrypted.db
sqlite> PRAGMA key = 'testkey';
sqlite> ATTACH DATABASE 'plaintext.db' AS plaintext KEY ''; -- empty key will disable encryption
sqlite> SELECT sqlcipher_export('plaintext');
sqlite> DETACH DATABASE plaintext;
Example 3: Convert from a 1.1.x to 2.0Database with HMAC
$ ./sqlcipher 1.1.x.db
sqlite> PRAGMA key = 'testkey';
sqlite> PRAGMA cipher_use_hmac = OFF; -- disable HMAC on main database
sqlite> ATTACH DATABASE '2.0.db' AS newdb; -- new database will use default HMAC setting, ON, with same key as the main database
sqlite> SELECT sqlcipher_export('newdb');
sqlite> DETACH DATABASE newdb;
Example 4: Changing Cipher Settings
$ ./sqlcipher encrypted.db
sqlite> PRAGMA key = 'testkey';
sqlite> ATTACH DATABASE 'newdb.db' AS newdb KEY 'newkey';
sqlite> PRAGMA newdb.cipher_page_size = 4096;
sqlite> PRAGMA newdb.cipher = 'aes-256-cfb';
sqlite> PRAGMA newdb.kdf_iter = 10000;
sqlite> SELECT sqlcipher_export('newdb');
sqlite> DETACH DATABASE newdb;
PRAGMA cipher_migrate
> ./sqlcipher 2xdatabase.db
> PRAGMA key = 'YourKeyGoesHere';
> PRAGMA cipher_migrate;
PRAGMA cipher_profile
$ ./sqlcipher example.db
sqlite> PRAGMA cipher_profile='sqlcipher.log';
sqlite> CREATE TABLE t1(a,b);
sqlite> INSERT INTO t1(a,b) VALUES('one for the money', 'two for the show');
sqlite> PRAGMA cipher_profile=off;
PRAGMA cipher_add_random
PRAGMA cipher_add_random = "x'deadbaad'";
PRAGMA cipher_provider
PRAGMA cipher_provider_version
PRAGMA cipher_version
$ ./sqlcipher example.db
sqlite> PRAGMA cipher_version;
3.3.1
sqlite3_key() and sqlite3_key_v2()
/*
** Specify the key for an encrypted database. This routine should be
** called right after sqlite3_open().
**
** The code to implement this API is not available in the public release
** of SQLite.
*/
int sqlite3_key(
sqlite3 *db, /* Database to be rekeyed */
const void *pKey, int nKey /* The key, and the length of the key in bytes */
);
int sqlite3_key_v2(
sqlite3 *db, /* Database to be rekeyed */
const char *zDbName, /* Name of the database */
const void *pKey, int nKey /* The key */
);
sqlite3_rekey() sqlite3_rekey_v2()
/*
** Change the key on an open database. If the current database is not
** encrypted, this routine will encrypt it. If pNew==0 or nNew==0, the
** database is decrypted.
**
** The code to implement this API is not available in the public releasejavascript:noop()
** of SQLite.
*/
int sqlite3_rekey(
sqlite3 *db, /* Database to be rekeyed */
const void *pKey, int nKey /* The new key, and the length of the key in bytes */
);
int sqlite3_rekey_v2(
sqlite3 *db, /* Database to be rekeyed */
const char *zDbName, /* Name of the database */
const void *pKey, int nKey /* The new key */
);
声明:
本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:
https://www.wpsshop.cn/w/小丑西瓜9/article/detail/492387
推荐阅读
article
数据库
连接工具
Navicat
查看并导出
ER
图
&&
数据库
使用&&支持
MySQL
、
MariaDB
、Mon...
实际应用项目:http://github.crmeb.net/u/long
Navicat
查看
ER
图
打开
数据库
表 可以看到...
赞
踩
article
Android
studio
中使用
sqlite
_
android
studio
sqlite
...
你可以根据自己的需求进行更复杂的操作,比如使用参数化查询、使用。类中,我们设置了数据库的版本号。每当你对数据库结构进行更...
赞
踩
article
主流常见关系数据库分页
sql
语句写法
limit
、
offset
、
fetch
、
rownum
。
MySQL
、...
select * from demo
limit
10
offset
20;select * from demo lim...
赞
踩
article
SQLite
的
命令行
Shell
(三十一)...
SQLite
拥有别人无法比拟
的
装机量,究竟什么成就了
SQLite
呢,本文将
SQLite
的
历史版本记录粗列一下,供各位朋友...
赞
踩
article
【
数据库
】
SQLite3
&
Navicat
for
Premium12
(中文破解)安装教程_navic...
目录一、安装SQLite(一)下载SQLite(二) 创建一个SQLite
数据库
二、安装
Navicat
for
Prem...
赞
踩
article
Android
之
数据
存储
与
访问 —— 初见
SQLite
数据
库
_
android
数据
库
...
本节我们继续来学习
Android
数据
存储
与
访问的第三种方式:
SQLite
数据
库
,和其他的SQL
数据
库
不同, 我们并不需要...
赞
踩
article
.Net
SQLite
简单使用...
【代码】.Net
SQLite
小工具。_.net sqlite.net sqlite 安装Nu...
赞
踩
article
ASP
.
NET
Core
使用
SQLite
教程,EF
SQLite
教程,修改
模型
更新
数据库
,适合...
SQLIte 操作方便,简单小巧,这里笔者就不再过多介绍,感兴趣可以到以下博文https://blog.csdn.net...
赞
踩
article
.
NET
中使用
SQLite
超精简
数据库
,无需任何客户端安装_.
net
sqlite
...
数据库
是软件中非常常用,但是在有一些场景我们需要用到
数据库
基础功能,但是却不想强制客户端安装任何
数据库
软件和
数据库
管理软...
赞
踩
article
.
net
中
使用
sqlite
(普通版)
_.
net
sqlite
...
要在.NET中
使用
SQLite,您需要安装SQLite的ADO.NET提供程序。安装完成后,您可以在您的项目中引用SQL...
赞
踩
article
SQLite
-
net
...
SQLite
-
net
SQLite
-
net
是一个轻量级的C#数据库库,可以让你在.NET应用程序中轻松地与
SQLite
数据...
赞
踩
article
七天.
NET
8操作
SQLite
入门到实战 - 第五天引入
SQLite
-
net
ORM
并封装常用方法...
上一章节我们搭建好了Easy
SQLite
的前后端框架,今天我们的主要任务是在后端框架中引入
SQLite
-
net
ORM
并...
赞
踩
article
Could
not
find
encoder
for
codec
id 27: Encoder no...
在detectron2测试demo时出现如题所示问题,解决:改:fourcc=cv2.VideoWriter_fourc...
赞
踩
article
ffmpeg
报错Encoder (
codec
h264
)
not
found
for
output
...
使用
ffmpeg
制作流媒体的视频文件,同样的命令在本地的windows环境是正常的,在linux 上就不行了。报错了根...
赞
踩
article
OpenCV 报错:FFMPEG: tag
0x34363258
/‘
X264
‘ is not sup...
OpenCV VideoWriter报错:FFMPEG: tag
0x34363258
/'
X264
' is not su...
赞
踩
article
【
FFmpeg
系列】编解码(六)_
decoder
(
codec
none)
not
found
f...
1、
FFmpeg
对 H264 进行编码API:// 查找编码器av
codec
_find_en...
赞
踩
article
解决:
OpenCV
:
FFMPEG
: tag
0x5634504d
/‘MP4V‘ is not su...
问题描述:利用python 的
opencv
包把图片合并为视频(
mp4
格式)的时候发现错误。
OpenCV
:
FFMPEG
:...
赞
踩
article
解决:
OpenCV
:
FFMPEG
:
tag
0x44495658
/‘
XVID
‘ is not su...
解决:
OpenCV
:
FFMPEG
:
tag
0x44495658
/‘
XVID
’ is not
suppo
rted wi...
赞
踩
article
报错OpenCV: FFMPEG: tag
0x5634504d
/‘MP4V‘ is not sup...
Video Detection Done!Save processed video to the path :0303....
赞
踩
article
解决:
OpenCV
:
FFMPEG
: tag
0x5634504d
/‘MP4V‘ is not su...
问题:利用python 的
opencv
包把图片合并为视频(mp4格式)时出现如下报错:
OpenCV
:
FFMPEG
: t...
赞
踩
相关标签
数据库
mysql
navicat
oracle
php
android studio
sqlite
android
sql
postgresql
分页
c++
SQLite3
Navicat for Premium
.net
测试
json
SQLite
超精简数据库
.NET SQLite