Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function decryptRoutine() {
var startTime = process.hrtime();
openpgp.decryptMessage(secretKey, encryptedMessage).then(function(text) {
var elapsed = process.hrtime(startTime);
secretKey = encryptedMessage = null
process.send({ method: MESSAGE_DECRYPT_TIME, timeElapsed: elapsed });
process.send({ method: DECRYPTED_TEXT, text: text });
setImmediate(function() {
process.exit(0);
});
}, d.bind(function(err) {
// Throw error to trigger crash
throw err;
}));
}
for(var l = 4; l < deprofaned.length - 1; l++) {
var original_line = deprofaned[l].split(' ');
var new_line = "";
for(var sym = 0; sym < original_line.length; sym++) {
var symbol_index = profanity.indexOf(original_line[sym]);
new_line += originalSymbols[symbol_index];
}
deprofaned[l] = new_line;
}
deprofaned = deprofaned.join('\n');
var message = openpgp.message.readArmored(deprofaned);
var keyids = message.getEncryptionKeyIds();
privKey.decryptKeyPacket(keyids, ur_private_key_pass);
openpgp.decryptMessage(privKey, message).then(function(pgpMessage) {
console.log(pgpMessage);
}).catch(function(err) {
throw err;
});
}
}).spread((text, pgpkey) => openpgp.decryptMessage(pgpkey, openpgp.message.readArmored(text)))
}
if (!privateKey.decrypt(password)) {
var error = new Error('Password is malformed');
error.name = 'Illegal Argument';
return callback(error, null);
}
pgpMessage = openpgp.message.readArmored(pgpMessage);
if (!pgpMessage) {
var error = new Error('Could not read the message');
error.name = 'InternalError';
return callback(error, null);
}
openpgp.decryptMessage(privateKey, pgpMessage).then(function(plaintext) {
var jsonData = JSON.parse(plaintext);
return callback(null, jsonData);
}).catch(function(err) {
if (err.action) {
callback(err, null);
}
});
},
],
}).then((km) =>
openpgp.decryptMessage(km, openpgp.message.readArmored(text))
);