UNPKG

@meeco/cryppo

Version:

In-browser encryption and decryption. Clone of Ruby Cryppo

24 lines 959 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.generateDerivedKey = generateDerivedKey; const derived_key_js_1 = require("./derived-key.js"); /** * Given a password/phrase, derive a fixed-length key from it using Pbkdf2Hmac. * Various derivation arguments can be provided to ensure deterministic results * (i.e. to derive the same key again from the same password/phrase). */ async function generateDerivedKey({ passphrase, length, minIterations, iterationVariance, useSalt, }) { const derivedKeyOptions = derived_key_js_1.DerivedKeyOptions.randomFromOptions({ iterationVariance, length, minIterations, strategy: derived_key_js_1.KeyDerivationStrategy.Pbkdf2Hmac, useSalt, }); const derivedKey = await derivedKeyOptions.deriveKey(passphrase); return { key: derivedKey, options: derivedKeyOptions, }; } //# sourceMappingURL=pbkdf2-hmac.js.map