rsa -- A deno library for RSA public/private key encryption/decryption

Import

import * as rsa from "https://deno.land/x/rsa/mod.ts"

Example

import * as rsa from "https://deno.land/x/rsa/mod.ts"

let key = rsa.genKeyPair()

console.log('key=', key)

let m = 123456789n
let c = rsa.encrypt(key, m)
let m2 = rsa.decrypt(key, c)
console.log('m=', m)
console.log('c=', c)
console.log('m2=', m2)

Run

$ deno run rsa_ex1.js 
key= {
  e: 6362587161218005124718929643036970100124234678153215537494151966808670165192690796728478501471872367n,
  d: 17227553622517262601479157461939274952741390058804759227795318497302129022295856443677676463806839829763278301875862959567239633852369181608340267429802504571576404064267181374844872462006080252100103n,
  N: 34927664739671877468262214354380113862001933257485553292587750088392443755084490269312604251353380046496510985064362138416594078941564145998696273971517867434073605855445753323536656266115845580783423n
}
m= 123456789n
c= 13520917851307896541810193744709031072878206517401868042404467018760773528294700947238121935755179496379752277502633944152496052591649114929063875469465616537296719558820915730364509640363807535429699n
m2= 123456789n