Newer
Older
alert / js / node_modules / public-encrypt / withPublic.js
@Réz István Réz István on 18 Nov 2021 275 bytes first commit
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