Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
(async () => {
(await argon2.hash(mandatoryOptions)).encoded; // string
(await argon2.hash(mandatoryOptions)).hash; // Uint8Array
(await argon2.hash(mandatoryOptions)).hashHex; // string
(await argon2.hash({ ...mandatoryOptions, distPath: 'path' })).encoded; // string
(await argon2.hash({ ...mandatoryOptions, hashLen: 24 })).encoded; // string
(await argon2.hash({ ...mandatoryOptions, mem: 1024 })).encoded; // string
(await argon2.hash({ ...mandatoryOptions, parallelism: 1 })).encoded; // string
(await argon2.hash({ ...mandatoryOptions, time: 1 })).encoded; // string
(await argon2.hash({ ...mandatoryOptions, type: argon2.ArgonType.Argon2d })).encoded; // string
(await argon2.hash({ ...mandatoryOptions, type: argon2.ArgonType.Argon2i })).encoded; // string
await argon2.verify(verifyOptions); // undefined
argon2.unloadRuntime(); // void
})();
(async () => {
(await argon2.hash(mandatoryOptions)).encoded; // string
(await argon2.hash(mandatoryOptions)).hash; // Uint8Array
(await argon2.hash(mandatoryOptions)).hashHex; // string
(await argon2.hash({ ...mandatoryOptions, distPath: 'path' })).encoded; // string
(await argon2.hash({ ...mandatoryOptions, hashLen: 24 })).encoded; // string
(await argon2.hash({ ...mandatoryOptions, mem: 1024 })).encoded; // string
(await argon2.hash({ ...mandatoryOptions, parallelism: 1 })).encoded; // string
(await argon2.hash({ ...mandatoryOptions, time: 1 })).encoded; // string
(await argon2.hash({ ...mandatoryOptions, type: argon2.ArgonType.Argon2d })).encoded; // string
(await argon2.hash({ ...mandatoryOptions, type: argon2.ArgonType.Argon2i })).encoded; // string
await argon2.verify(verifyOptions); // undefined
argon2.unloadRuntime(); // void
})();
static async hash(value: string) {
const salt = window.crypto.getRandomValues(new Uint8Array(16));
const hash = await argon2.hash({
pass: value,
salt,
mem: 1024 * 16,
type: argon2.ArgonType.Argon2id
});
return hash.encoded;
}