less than 1 minute read

npm npm bundle size codesize npm NPM GitHub Sponsors GitHub Repo stars GitHub forks GitHub watchers Rate on Openbase link to npm

jwt-authn

Generating RSA256 private and public key pair

Full Documentation

with javascript

import crypto from "crypto";

const { publicKey, privateKey } = crypto.generateKeyPairSync(
  "rsa",
  {
    modulusLength: 4096,
    publicKeyEncoding: {
      type: "spki",
      format: "pem",
    },
    privateKeyEncoding: {
      type: "pkcs8",
      format: "pem",
      cipher: "aes-256-cbc",
      passphrase: "top secret", // this creates an encrypted private key. Make sure to pass it in when trying to sign a JWT. Omit for an unencrypted private key.
    },
  }
);

or from a bash shell

ssh-keygen -t rsa -b 4096 -m PEM -f jwtRS256.key