Skip to content

Instantly share code, notes, and snippets.

@efleming969
Created November 30, 2021 13:28
Show Gist options
  • Save efleming969/4d930025aa544329353b141c4f3744fa to your computer and use it in GitHub Desktop.
Save efleming969/4d930025aa544329353b141c4f3744fa to your computer and use it in GitHub Desktop.
utility for create public/private keys
import * as FS from "fs"
import * as Jose from "jose"
const { publicKey, privateKey } = await Jose.generateKeyPair( "RS256" )
const publicPem = await Jose.exportSPKI( publicKey )
await FS.promises.writeFile( "./public.pem", publicPem, "utf-8" )
const privatePem = await Jose.exportPKCS8( privateKey )
await FS.promises.writeFile( "./private.pem", privatePem, "utf-8" )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment