admin_vue/11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/public-encrypt/withPublic.js

13 lines
275 B
JavaScript
Raw Normal View History

2022-11-20 18:09:32 +08: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