i have sketch which the decrypt password from file info.txt and send me mail when i go to http://localhost:8080:
var crypto = require('crypto'); // encryption/decryption tool
var fs = require('fs'); // filesystem manager
var express = require('express'); // web server
var nodemailer = require('nodemailer'); // email
var key = process.argv[3];
var fileName = __dirname + "/info.txt";
var decipher = crypto.createDecipher('aes-256-cbc', key);
var server = express();
server.use('/',express.static('public'));
var account = {
host: 'smtp.gmail.com', // mail server
port: 465, // SSL mail port
secure: true, // using secure sockets for mail
auth: {
user: process.argv[2], // username from the commnand line
pass: '' // password will come from decryption later
}
};
var message = {
from: account.auth.user,
to: 'z.zitsw@gmail.com', //''cat.owner@example.com',
subject: 'Hello from the cat',
text: 'The cat is sitting on his mat! http://www.example.com/catcam.html'
};
function sendMail(request, response) {
// callback function to confirm mail was sent and inform web client
var mailClient = nodemailer.createTransport(account);
var responseString = mailClient.sendMail(message, confirmMail);
}
function decryptFile(error, data) {
// if there's valid data from the file, decrypt it:
if (data){
var content = data.toString();
var decryptedPassword = decipher.update(content, 'hex', 'utf8');
decryptedPassword += decipher.final('utf8');
account.auth.pass = decryptedPassword;
// if the file produces an error, report it:
} else if (error) {
console.log(error);
}
}
// read from the password file:
fs.readFile(fileName, decryptFile);
console.log("credentials for " + account.auth.user + " obtained.");
// start the server:
server.listen(8080);
server.get('/mail', sendMail); // send a mail
console.log("waiting for web clients now.");
but when i run app in terminal (node server.js my_mail key) i take this error:
(node:7392) [DEP0106] DeprecationWarning: crypto.createDecipher is deprecated.
(Use node --trace-deprecation ...
to show where the warning was created)
internal/validators.js:198
throw new ERR_INVALID_ARG_VALUE('encoding', encoding
Please help me
So to me that's saying that the function createDecipher is no longer supported? Maybe if you look into the documentation for the crypto package there could be an explanation or alternative to solve this.