@privy-io/crypto
JavaScript library for encrypting and decrypting data with Privy.
Usage
import {CryptoEngine, CryptoVersion} from 'privy-crypto-js';
const x0 = CryptoEngine(CryptoVersion.x0);
const plaintext = Buffer.from('{"ssn": "123-45-6789"}');
const privyEncryption = new x0.Encryption(plaintext, {
wrapperKey: wrapperKey,
wrapperKeyId: wrapperKeyId,
});
const encryptionResult = await privyEncryption.encrypt();
const ciphertext = encryptionResult.ciphertext();
const privyDecryption = new x0.Decryption(ciphertext);
const decryptedDataKey = decryptDataKey(
privyDecryption.wrapperKeyId('utf8'),
privyDecryption.encryptedDataKey('base64')
);
const decryptionResult = await privyDecryption.decrypt(decryptedDataKey);
console.log(decryptionResult.plaintext('utf8'));
Running tests
npm test