One API, two runtimes
Use native Node crypto on the server and Web Crypto in the browser. Share keys, payloads, and TypeScript types.
Runtime compatibility
RSA encryption, authenticated JSON, and signed messages with one async API for Node.js and browsers.
npm install encrypt-rsaimport NodeRSA from 'encrypt-rsa';
const rsa = new NodeRSA();
const { publicKey, privateKey } = await rsa.createPrivateAndPublicKeys(2048);
const text = await rsa.encryptJSON({
value: { message: 'Hello, العربية 😀' },
publicKey,
});
const value = await rsa.decryptJSON({ text, privateKey });JSON uses authenticated v1 hybrid encryption with RSA-OAEP/SHA-256. Keep private keys in trusted application storage and validate decrypted data before using it.