Documentation
    Preparing search index...

    Hash driver built on top of "argon2" hash algorigthm. Under the hood we make use of the "argon2" npm package.

    The Argon implementation uses the PHC formatting for creating and verifying hashes.

    const argon = new Argon({})

    await argon.make('secret')
    // $argon2id$v=19$t=3,m=4096,p=1$drxJBWzWahR5tMubp+a1Sw$L/Oh2uw6QKW77i/KQ8eGuOt3ui52hEmmKlu1KBVBxiM

    Implements

    Index

    Constructors

    Methods

    • Check if the value is a valid hash. This method just checks for the formatting of the hash.

      argon.isValidHash('hello world') // false
      argon.isValidHash('$argon2id$v=19$t=3,m=4096,p=1$drxJBWzWahR5tMubp+a1Sw$L/Oh2uw6QKW77i/KQ8eGuOt3ui52hEmmKlu1KBVBxiM')

      Parameters

      • value: string

        The value to check

      Returns boolean

      True if the value is a valid Argon2 hash format

    • Hash a plain text value

      const hash = await argon.make('password')
      

      Parameters

      • value: string

        The plain text value to hash

      Returns Promise<string>

      Promise resolving to the Argon2 hash

    • Verify the plain text value against an existing hash

      if (await argon.verify(hash, plainText)) {

      }

      Parameters

      • hashedValue: string

        The hashed value to verify against

      • plainValue: string

        The plain text value to verify

      Returns Promise<boolean>

      Promise resolving to true if verification succeeds

    • Find if the hash value needs a rehash or not. The rehash is required when.

      1. The argon2 version is changed
      2. Number of iterations are changed
      3. The memory value is changed
      4. The parellelism value is changed
      5. The argon variant is changed
      6. The provided hash has not been hashed with argon
      const isValid = await argon.verify(hash, plainText)

      // Plain password is valid and hash needs a rehash
      if (isValid && await argon.needsReHash(hash)) {
      const newHash = await argon.make(plainText)
      }

      Parameters

      • value: string

        The hashed value to check

      Returns boolean

      True if the hash needs to be rehashed