Skip to content

argon2.verify() documentation in README.md is wrong #95

Open
@enspritz

Description

README.md says:

argon2.verify({
    // <CODE ELIDED>
})
// result
.then(res => {
    res.hash // hash as Uint8Array
    res.hashHex // hash as hex-string
    res.encoded // encoded hash, as required by argon2
})
// or error
.catch(err => {
    err.message // error message as string, if available
    err.code // numeric error code
})

Which is desirable! I need res.hash after a successful verification. But, meanwhile, back in argon2.js:

  let result;
  if (res || err) {
    // <CODE ELIDED>
    result = { message: err, code: res };
  }
  // <CODE ELIDED>
  if (err) {
    throw result;
  } else {
    return result;
  }

.. returning undefined in the case of success. And indeed argon2_library.c indicates we can only receive a status code and not the various hash values:

  ret = argon2_verify_ctx(&ctx, (char *)desired_result, type);

SO, the res data structure containing encoded, hash, hashHex needs to be re-written out of the README.md sample .then() clause , perhaps like this:

argon2.verify({
    // <CODE ELIDED>
})
// success
then(() => console.log("success!"))
// or error
.catch(err => {
    err.message // error message as string, if available
    err.code // numeric error code
})

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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