我正在使用 Node.js 和 Mysql,我想加密我数据库中的数据。
我想知道如何避免将普通 key 存储在一个很容易找到的文件中,执行 AES_ENCRYPT(text, key)
对我来说没有意义,因为我传递了一个别人可以在服务器上读取没有问题。
有什么建议吗? 非对称密码学?
谢谢
最佳答案
您可以让用户在启动时提供 key ,使用 readline
模块:
您的应用:
module.exports = function(key) {
var app = // ...
}
您的启动脚本:
var readline = require('readline')
, interface = readline.createInterface(process.stdin, process.stdout, null);
interface.question("Please supply a key", function(key) {
// load your app, supplying the key
require("./app")(key);
interface.close();
process.stdin.destroy();
});
关于javascript - 如何避免普通文件中的 key ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9375215/