Your IP : 216.73.216.209


Current Path : /usr/share/nodejs/public-encrypt/
Upload File :
Current File : //usr/share/nodejs/public-encrypt/withPublic.js

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