Documentation
    Preparing search index...

    Hash and verify values using a dedicated hash driver. The Hash works as an adapter across different drivers.

    const hash = new Hash(new Argon())
    const hashedPassword = await hash.make('secret')

    const isValid = await hash.verify(hashedPassword, 'secret')
    console.log(isValid)

    Implements

    Index

    Constructors

    Methods

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

      Parameters

      • value: string

        The value to check

      Returns boolean

      True if the value is a valid hash format

    • Hash plain text value

      Parameters

      • value: string

        The plain text value to hash

      Returns Promise<string>

      Promise resolving to the hashed value

    • Verify the plain text value against an existing hash

      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.

      Parameters

      • hashedValue: string

        The hashed value to check

      Returns boolean

      True if the hash needs to be rehashed

    • Assert the plain value passes the hash verification

      Parameters

      • hashedValue: string

        The hashed value to verify against

      • plainValue: string

        The plain text value to verify

      Returns Promise<void>

      Promise that resolves if verification passes, throws if it fails

    • Assert the plain value fails the hash verification

      Parameters

      • hashedValue: string

        The hashed value to verify against

      • plainValue: string

        The plain text value to verify

      Returns Promise<void>

      Promise that resolves if verification fails, throws if it passes