GoScrobble/web/node_modules/public-encrypt/withPublic.js

13 lines
275 B
JavaScript
Raw Permalink Normal View History

2022-04-25 02:47:15 +00:00
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