Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | 2x 2x 2x 1x 1x 2x 1x 1x 16x 2x | import argon2, { ArgonType } from 'argon2-browser'; import { memoizeWith, identity } from 'ramda'; export async function deriveKey({ pass, salt }: { pass: string; salt: string }) { const result = await argon2.hash({ pass, salt, hashLen: 48, time: 44, mem: 1024 * 32, type: ArgonType.Argon2id, }); return { derivedKeyHash: result.hash }; } export function generateRandomHexString() { const size = 16; const randomValues = [...crypto.getRandomValues(new Uint8Array(size))]; return randomValues.map(val => ('00' + val.toString(16)).slice(-2)).join(''); } export const generateSalt = memoizeWith(identity, () => generateRandomHexString()); |