README
seed-wasm
wasm enhanced seed crypto library for javascript requires wasm modules and simd.
API
interface SEEDOptions {
key: Uint8Array;
mode: 'SEED-CBC';
}
export declare class SEED {
constructor(options: SEEDOptions);
encrypt(input: Uint8Array, iv: Uint8Array): Uint8Array;
decrypt(cipher: Uint8Array, iv: Uint8Array): Uint8Array;
}
Example
node --experimental-wasm-modules test.js
// test.js
import { randomBytes } from 'crypto';
import SEED from 'seed-wasm';
const key = randomBytes(16);
const iv = randomBytes(16);
const seed = new SEED({ key, mode: 'SEED-CBC' });
const plain = `Hello World`;
const cipher = Buffer.from(seed.encrypt(Buffer.from(plain), iv));
const decrypted = Buffer.from(seed.decrypt(cipher, iv)).toString();
console.log({ key, plain, cipher, decrypted });