Skip to content

encrypt-rsaProtect app data and AI memory.

RSA encryption, authenticated JSON, and signed messages for Node.js and browsers. Explore recipes for encrypted AI memory and conversation storage.

AI memory is validated as JSON, encrypted with AES and RSA, and saved as ciphertext.
AI INTEGRATIONS

Build encrypted AI memory and chat history.

Use the same JSON and signature APIs around your AI application. Start with a focused recipe, then adapt it to your storage and authentication.

Separate examples, lightweight core. AI SDK lives in the example app. Encryption protects stored data; your application and any model provider receiving it can see the plaintext.

From install to encrypted JSON ​

bash
npm install encrypt-rsa
ts
import 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.

Follow the setup guide → · Validate a JSON schema → · Read the complete API →

Find the right guide ​

You want to…Start here
Install the package and generate keysGetting started
Encrypt application dataJSON and schema validation or text and binary APIs
Build an AI integrationAI overview and setup
Authenticate an expiring messageSigned messages and replay prevention
Move between Node.js and browsersRuntime compatibility
Upgrade an existing installationMigration guide

Released under the MIT License.