One API, zero runtime dependencies
Use native Node crypto and browser Web Crypto. Share keys, payloads, and TypeScript types with one async API.
Runtime compatibility
RSA encryption, authenticated JSON, and signed messages for Node.js and browsers. Explore recipes for encrypted AI memory and conversation storage.
Use the same JSON and signature APIs around your AI application. Start with a focused recipe, then adapt it to your storage and authentication.
Bind records to a tenant and user, handle revision conflicts, and rotate encryption keys.
Open guide CONVERSATIONSValidate full message history and save completed generations, including tool results and metadata.
Open guide ASSISTANTRun the local docs assistant with offline fixtures. Choose a runtime and operation to get a matching example.
Open guide MESSAGESCheck signed payloads, expected identities, expiry, and replay before using an agent result.
Open guideSeparate 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.
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.
Follow the setup guide → · Validate a JSON schema → · Read the complete API →
| You want to… | Start here |
|---|---|
| Install the package and generate keys | Getting started |
| Encrypt application data | JSON and schema validation or text and binary APIs |
| Build an AI integration | AI overview and setup |
| Authenticate an expiring message | Signed messages and replay prevention |
| Move between Node.js and browsers | Runtime compatibility |
| Upgrade an existing installation | Migration guide |