Skip to content

Instantly share code, notes, and snippets.

View emmanuel-2u's full-sized avatar

Afolabi Gboyega emmanuel-2u

View GitHub Profile
@sohamkamani
sohamkamani / rsa.js
Last active July 4, 2024 13:04
An example of RSA Encryption implemented in Node.js
const crypto = require("crypto")
// The `generateKeyPairSync` method accepts two arguments:
// 1. The type ok keys we want, which in this case is "rsa"
// 2. An object with the properties of the key
const { publicKey, privateKey } = crypto.generateKeyPairSync("rsa", {
// The standard secure default length for RSA keys is 2048 bits
modulusLength: 2048,
})