• File: withPublic.js
  • Full Path: /var/www/imalireports/node_modules/public-encrypt/withPublic.js
  • Date Modified: 11/01/2022 10:15 PM
  • File size: 275 bytes
  • MIME-type: text/plain
  • Charset: utf-8
var BN = require('bn.js')
var Buffer = require('safe-buffer').Buffer

function withPublic (paddedMsg, key) {
  return Buffer.from(paddedMsg
    .toRed(BN.mont(key.modulus))
    .redPow(new BN(key.publicExponent))
    .fromRed()
    .toArray())
}

module.exports = withPublic