-2
누구든지 node.js에서 jsonfile을 암호화하고 암호 해독하는 방법을 말할 수 있습니까? 나는이 프로그램을 시험해 본 결과 파일 암호 tty.setrawmode가 함수가 아니라는 오류를 보여준다.node.js의 json 파일을 암호화하고 암호 해독
일반 텍스트 파일 :
{
"production" : {
"db" : {
"database" : "mysql",
"user" : "root",
"password" : "bdwb ve13hb3"
},
"app" : {
"port" : 8086
}
}
}
암호화 :
이var SecureConf = require('secure-conf');
var sconf = new SecureConf();
sconf.encryptFile(
"./test.json",
"./test.json.enc",
function(err, f, ef, ec) {
if (err) {
consoel.log("failed to encrypt %s, error is %s", f, err);
} else {
console.log("encrypt %s to %s complete.", f, ef);
console.log("encrypted contents are %s", ec);
}
}
);
암호 해독 : sconf.encryptFile
이 세 개의 인수로 호출
var SecureConf = require('secure-conf');
var sconf = new SecureConf();
var ef = "./test.json.enc";
var express = require('express');
var app = express();
sconf.decryptFile(ef, function(err, file, content) {
if (err) {
console.log('Unable to retrieve the configuration contents.');
} else {
var config = JSON.parse(content);
app.listen(config.production.app.port);
}
});
Bro, 출력을 얻을 수 없습니다. 지침을 따랐습니다. 텍스트로 세 번째 매개 변수를 추가했습니다. 암호화 프로그램을 웹 스톰 터미널에서 처음 실행합니다. 동일한 오류를 보여줍니다. 정확한 코드를 보내주십시오. 암호화 및 암호 해독. 이것은 내 메일 ID입니다 : [email protected] 미리 감사드립니다. 귀하의 회신을 기다리고 있습니다 ... – vigneshRavi
죄송하지만, 나는 형제가 아닙니다. 나는'sconf.encryptFile'의 소스 코드를 들여다 보았습니다. 나는이 코드를 실제로 실행하지 않았다. –