node-sqlcipher
https://github.com/journeyapps/node-sqlcipher
Windows-Build-Tools
https://github.com/felixrieseberg/windows-build-tools
DB Browser for SQLite
sequelize
https://github.com/sequelize/sequelize
Sequelize using SQLcipher to encrypt DB
https://github.com/sequelize/sequelize/issues/11603
SQLCipher為SQLite的數據加密解決方案,而node-sqlcipher是Javascript的SQLCipher版本,在Windows安裝需要通過:
1. Visual Studio 2015
2. Python 2.7
一、安裝@journeyapps/sqlcipher方式:
1. visual studio code得使用系統管理員權限開啟
2. 開啟專案資料夾,確定路徑內不能含有中文,否則python2.7無法接受
3. 先安裝windows-build-tools並指定安裝vs2015,使用指令安裝至全域: npm i -g windows-build-tools --vs2015
4. 安裝@journeyapps/sqlcipher: npm i @journeyapps/sqlcipher
二、若是通過sequelize來操作加密sqlite,可使用如下程式碼:
const sequelize = new Sequelize('database', '', 'your-encryption-key' {
dialect: 'sqlite',
dialectModulePath: '@journeyapps/sqlcipher',
storage: 'path/to/db.sqlite',
});
//設定密鑰相容性與加密密碼
sequelize.query('PRAGMA cipher_compatibility = 3');
sequelize.query("PRAGMA key = 'your-encryption-key'");
三、查看加密sqlite的數據可使用DB Browser for SQLite免安裝版。
#sqlite, node-sqlcipher, Windows-Build-Tools, Visual Studio 2015, Python 2.7, @journeyapps/sqlcipher, sequelize, DB Browser for SQLite
留言
張貼留言