sqlcipher命令行加密解密数据库

sqlcipher命令行加密解密数据库

对未加密数据库进行加密

.\sqlcipher.exe ./origin.db
SQLCipher version 3.30.1 2019-10-10 20:19:45
Enter ".help" for usage hints.
sqlite> ATTACH DATABASE 'encrypt.db' AS encrypt KEY '123';
sqlite> SELECT sqlcipher_export ('encrypt');
sqlite> DETACH DATABASE encrypt;
sqlite> .q

对加密数据库进行解密

.\sqlcipher.exe ./encrypt.db
SQLCipher version 3.30.1 2019-10-10 20:19:45
Enter ".help" for usage hints.
sqlite> PRAGMA KEY='123';
sqlite> ATTACH DATABASE 'decrypt.db' AS decrypt KEY '123';
sqlite> SELECT sqlcipher_export ('decrypt');
sqlite> DETACH DATABASE decrypt;
sqlite> .q

对加密数据库修改密码

.\sqlcipher.exe ./encrypt.db
SQLCipher version 3.30.1 2019-10-10 20:19:45
Enter ".help" for usage hints.
sqlite> PRAGMA KEY='123';   //先输入旧密码
sqlite> PRAGMA REKEY='123';  //新密码
sqlite> .q

命令行版sqlcipher可执行文件下载

你可能感兴趣的:(数据库)