I am having trouble getting crypto_pwhash_str
working in my Node project. I imported the libsodium-wrappers-sumo and libsodium-sumo libraries properly and am able to call other functions with success. My call to the problematic function looks like this:
sodium.crypto_pwhash_str(password, 3, 4096, 'text')
In this case, password is just a string object with the letter 'a'.
When I run the debugger and try to figure out what is going wrong I get to this internal block of code:
if ((libsodium._crypto_pwhash_str(hashed_password_address, password_address, password_length, 0, opsLimit, 0, memLimit) | 0) === 0) {
var ret = libsodium.Pointer_stringify(hashed_password_address);
_free_all(address_pool);
return ret;
}
_free_and_throw_error(address_pool);
It fails to enter the for loop and the call to _crypto_pwhash_str()
evaluates to -1
for some reason.
Does anyone have any experience with this library or can help me figure out what I am doing wrong. Fairly new to Node so I am quite lost.
Figured it out. I (for some silly reason) thought that memlimit
, which I set to 4096, was measured in MB, Apparently it is measured in kilobytes and has a MINIMUM value acceptable of 32768 (32 MB). It now works!