【问题标题】:how to send encrypted message via nodejs?如何通过nodejs发送加密消息?
【发布时间】:2018-09-23 01:09:39
【问题描述】:

我通过 postfix 邮件服务器发送电子邮件。 代码在 node.js 上使用 sendmail:

   const sendmail = require('sendmail')({
    logger: {
      debug: console.log,
      info: console.info,
      warn: console.warn,
      error: console.error
    },
    silent: true,
    smtpPort: 25, // Default: 25
      dkim: {
        privateKey: fs.readFileSync('mail_key.txt', 'utf8'),
        keySelector: 'mail'
      },
    smtpHost: 'mail.mydomain.com' // Default: -1 - extra smtp host after resolveMX
  })


const text = 'some text .... ';
  var mes=sendmail({
     from: ' "some sender" <info@mydomain.com',
     to: data.Email,
     subject: 'Your Account Data',
     html:text,
   }, function(err, reply) {
     console.log(err && err.stack);
     console.dir(reply);
   });

消息发送成功。但仍然是加密的。 我想知道如何发送要加密的电子邮件。 顺便说一句,我的连接之前使用 TLS 加密。我想加密消息内容。

【问题讨论】:

  • 你找到答案了吗?

标签: javascript node.js encryption smtp


【解决方案1】:

您可以使用bcrypt 包来加密您的字符串值,这是您可以使用它的方法:

  let text2 = 'some....';
  bcrypt.hash(text2, 10, (err, hash) => {
    if(err) throw err; 
    text = hash;
    console.log('happy hashing',text);
});

【讨论】:

  • 谢谢,但您的解决方案仅加密消息字符串。如果我发送这个消息文本将被加密接收。我想……像s/mime……
猜你喜欢
  • 2019-11-12
  • 1970-01-01
  • 1970-01-01
  • 2018-06-27
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-08-08
  • 1970-01-01
相关资源
最近更新 更多