timg safe compare token fixes #91

This commit is contained in:
Jan Prochazka
2021-04-30 17:21:35 +02:00
parent 4522c37bfa
commit bd6c116cc0
2 changed files with 11 additions and 1 deletions

View File

@@ -0,0 +1,9 @@
const crypto = require('crypto');
function timingSafeCheckToken(a, b) {
if (!a || !b) return false;
if (a.length != b.length) return false;
return crypto.timingSafeEqual(Buffer.from(a), Buffer.from(b));
}
module.exports = timingSafeCheckToken;