Skip to content

Example on how to verify a password from database #10

@immortalx

Description

@immortalx

I'm new to javascript so excuse me if this is trivial, it took me a while to figure it out so i think it should be good to include this in the example to save people some time.

To save the hash to db i need to convert it first to a string.
When a user logs in i need to create a new buffer with the saved hash in order to use the verify function.

Using Buffer.from returns the error
"Error: hashBuf must be HASH_BYTES (128)"
Because the buffer length is 96.

It should be something:

const savedHash = Buffer.alloc(securePassword.HASH_BYTES)
savedHash.write(dbhashedvalue)

Also from what i understand it's not possible to set the value of securePassword.HASH_BYTES right?

Thank you

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions