UNPKG

@akanass/rx-crypto

Version:

Crypto module provides some functions for security features like AES key, Key pair, RSA key, PKCS12, Certificate, PEM and more

21 lines (20 loc) 670 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.AES = void 0; const operators_1 = require("rxjs/operators"); const hash_1 = require("./hash"); class AES { constructor() { this._hash = new hash_1.Hash(); } createKey(password, salt) { return this._hash.generate(password, salt, 4096, 48, 'sha256') .pipe((0, operators_1.map)((derivedKey) => { const keyBuffer = Buffer.from(derivedKey); const key = keyBuffer.slice(0, 32).toString('hex'); const iv = derivedKey.slice(32).toString('hex'); return { key, iv }; })); } } exports.AES = AES;