Browser Demo - Web Crypto API Implementation
npm install asymmetric-cryptography-data-exchange-utils
// Node.js / ES Modules
import { createKeys, encryptWithPubKey, decryptWithPrivateKey } from 'asymmetric-cryptography-data-exchange-utils';
// Generate key pair
const keys = await createKeys();
// Encrypt with public key
const encrypted = await encryptWithPubKey("Hello World!", keys.publicKey);
// Decrypt with private key
const decrypted = await decryptWithPrivateKey(encrypted, keys.privateKey);
// Browser (CDN)
import { createKeys } from 'https://esm.sh/asymmetric-cryptography-data-exchange-utils';
// PEM String API
import { createKeysPEM, encryptWithPubKeyPEM, decryptWithPrivateKeyPEM } from 'asymmetric-cryptography-data-exchange-utils';
const pemKeys = await createKeysPEM();
const encrypted = await encryptWithPubKeyPEM("Hello!", pemKeys.publicKey);
const decrypted = await decryptWithPrivateKeyPEM(encrypted, pemKeys.privateKey);