Pubkeeper NOOP Crypto Plugin
This package provides the 'NONE'
encryption for the JavaScript pubkeeper client.
Installation
In a browser:
<script src="pubkeeper-crypto-none.js"></script>
Using npm:
$ npm install --save @pubkeeper/crypto-cjs-none
Then, load using ES5 require()
syntax…
var PubkeeperNoneCrypto =
require('@pubkeeper/crypto-cjs-none').PubkeeperNoneCrypto;
…or with ES2015+ import
syntax:
import { PubkeeperNoneCrypto } from '@pubkeeper/crypto-cjs-none';
Basic Syntax
Registering as a supported cipher in a PubkeeperClient…
const client = new PubkeeperClient({
crypto: new Map([
PubkeeperNoneCrypto,
]),
})
Registering as the default cipher in a PubkeeperClient…
const client = new PubkeeperClient({
crypto: new Map([
PubkeeperClient.setDefaultCrypto(PubkeeperNoneCrypto),
PubkeeperNoneCrypto,
]),
})
Using the cipher function directly.
const [,cipher] = PubkeeperNoneCrypto;
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"