@meeco/cryppo
Version:
In-browser encryption and decryption. Clone of Ruby Cryppo
21 lines • 829 B
JavaScript
import { DerivedKeyOptions, KeyDerivationStrategy } from './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).
*/
export async function generateDerivedKey({ passphrase, length, minIterations, iterationVariance, useSalt, }) {
const derivedKeyOptions = DerivedKeyOptions.randomFromOptions({
iterationVariance,
length,
minIterations,
strategy: KeyDerivationStrategy.Pbkdf2Hmac,
useSalt,
});
const derivedKey = await derivedKeyOptions.deriveKey(passphrase);
return {
key: derivedKey,
options: derivedKeyOptions,
};
}
//# sourceMappingURL=pbkdf2-hmac.js.map