UNPKG
choo-shortcache
Version:
latest (0.0.0)
0.0.0
choo nanocomponent cache shortcut
choo-shortcache
/
example
/
node_modules
/
public-encrypt
/
withPublic.js
13 lines
(10 loc)
•
275 B
JavaScript
View Raw
1
2
3
4
5
6
7
8
9
10
11
12
13
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