node-postgres icon indicating copy to clipboard operation
node-postgres copied to clipboard

cache password hash in SASL auth

Open matej21 opened this issue 3 years ago • 1 comments

In SASL auth handling, Hi function is called for every established connection although the password and hash are same. In my measurements, it takes 10-20ms to calculate the hash with default 4096 iterations. Caching the result of this function would significantly improve performance. What do you think? I can prepare PR.

matej21 avatar Sep 16 '22 09:09 matej21

Just find out, Hi function can be replaced with crypto.pbkdf2Sync(password, salt, 4096, 32, 'sha256'), which is like 20 times faster..

matej21 avatar Sep 16 '22 09:09 matej21