55555-Jyeon / Clerk_Lucia

Modern Authentication with NextJS (Clerk and Lucia)
0 stars 0 forks source link

argon2 #6

Open 55555-Jyeon opened 1 month ago

55555-Jyeon commented 1 month ago
documentation → 🔗 https://www.npmjs.com/package/@node-rs/argon2


use to hash password

install npm i @node-rs/argon2

55555-Jyeon commented 1 month ago

options

1️⃣ memoryCost?: number | undefined | null

The amount of memory to be used by the hash function, in kilobytes. Each thread will have a memory pool of this size. Note that large values for highly concurrent usage will cause starvation and thrashing if your system memory gets full.


2️⃣ memoryCost?: number | undefined | null

The time cost is the amount of passes (iterations) used by the hash function. It increases hash strength at the cost of time required to compute.


3️⃣ timeCost?: number | undefined | null

The hash length is the length of the hash function output in bytes. Note that the resulting hash is encoded with Base 64, so the digest will be ~1/3 longer.


4️⃣ outputLen?: number | undefined | null

The amount of threads to compute the hash on. Each thread has a memory pool with memoryCost size. Note that changing it also changes the resulting hash.

5️⃣ parallelism?: number | undefined | null

6️⃣ algorithm?: Algorithm | undefined | null

7️⃣ version?: Version | undefined | null

8️⃣ secret?: Buffer | undefined | null

55555-Jyeon commented 1 month ago

hashed

  // hash password
  const hashedPW = await hash(password, {
    memoryCost: 19485,
    timeCost: 2,
    outputLen: 32, // default
    parallelism: 1, // default
  });

  // check
  console.log("hashed?", { hashedPW });