sqlcipher如何导入一个sqlite3数据库

时间:2021-10-27 18:23:51

I have dumped a sqlite3 database into a .sql file. Afterwards I have import the files like this:

我将一个sqlite3数据库转储到.sql文件中。之后我导入文件如下:

cat databasedump.sql | sqlcipher encrypted_database

猫databasedump。sql | sqlcipher encrypted_database

Then I've opened the encrypted database and set the key with:

然后我打开加密的数据库,将密钥设置为:

pragma key="12345"

编译指示键= " 12345 "

then I close the database and reopen it, it's still not encrypted.

然后我关闭数据库并重新打开它,它仍然没有加密。

How can I load the dump in the database and encrypt it?

如何加载数据库中的转储并对其进行加密?

2 个解决方案

#1


1  

$ sqlcipher plaintext.db
sqlite> ATTACH DATABASE 'encrypted.db' AS encrypted KEY 'my password';
sqlite> SELECT sqlcipher_export('encrypted');
sqlite> DETACH DATABASE encrypted;

#2


1  

$ ./sqlcipher encrypted.db
sqlite> PRAGMA key = 'my password';
sqlite> ATTACH DATABASE 'plaintext.db' AS plaintext KEY '';  -- empty key will disable encryption`
sqlite> SELECT sqlcipher_export('plaintext');
sqlite> DETACH DATABASE plaintext;

#1


1  

$ sqlcipher plaintext.db
sqlite> ATTACH DATABASE 'encrypted.db' AS encrypted KEY 'my password';
sqlite> SELECT sqlcipher_export('encrypted');
sqlite> DETACH DATABASE encrypted;

#2


1  

$ ./sqlcipher encrypted.db
sqlite> PRAGMA key = 'my password';
sqlite> ATTACH DATABASE 'plaintext.db' AS plaintext KEY '';  -- empty key will disable encryption`
sqlite> SELECT sqlcipher_export('plaintext');
sqlite> DETACH DATABASE plaintext;