Pubkeeper AES-CBC Crypto Plugin
This package provides AES-CBC encryption for the JavaScript pubkeeper client, via crypto‑js
Installation
In a browser:
<script src="pubkeeper-crypto-aes-cbc.js"></script>
Using npm:
$ npm install --save @pubkeeper/crypto-cjs-aes-cbc
Then, load using ES5 require()
syntax…
var PubkeeperAesCbcCrypto =
require('@pubkeeper/crypto-cjs-aes-cbc').PubkeeperAesCbcCrypto;
…or with ES2015+ import
syntax:
import { PubkeeperAesCbcCrypto } from '@pubkeeper/crypto-cjs-aes-cbc';
Basic Syntax
Registering as a supported cipher in a PubkeeperClient…
const client = new PubkeeperClient({
crypto: new Map([
PubkeeperAesCbcCrypto,
]),
})
Registering as the default cipher in a PubkeeperClient…
const client = new PubkeeperClient({
crypto: new Map([
PubkeeperClient.setDefaultCrypto(PubkeeperAesCbcCrypto),
PubkeeperAesCbcCrypto,
]),
})
Using the cipher function directly.
const [,cipher] = PubkeeperAesCbcCrypto;
const key = new TextEncoder().encode('averyinsecurekey');
const c = cipher(key)
const ptext = new TextEncoder().encode('my message');
const ctext = c.encrypt(ptext)
const result = c.decrypt(ctext);
console.log(new TextDecoder().decode(result)); // "my message"