Files
boc/vims-backend/node_modules/scmp/index.js
T
Bernt 6de2455917 v1.2.0: Add Global Markets footer, translated to 9 languages
- Added GLOBAL_MARKETS_TITLE to all translation files
- Updated footer with 12 markets (4 active + 8 upcoming)
- Translated market section to: zh-cn, zh-tw, ja, ko, th, vi, id, ms, hi
- Built and deployed to production
- CloudFront invalidation: I3RTMXVFDJXWLG3SYX208OP1CC
2026-07-08 19:56:03 +00:00

34 lines
971 B
JavaScript

'use strict'
const crypto = require('crypto')
const scmpCompare = require('./lib/scmpCompare')
/**
* Does a constant-time Buffer comparison by not short-circuiting
* on first sign of non-equivalency.
*
* @param {Buffer} a The first Buffer to be compared against the second
* @param {Buffer} b The second Buffer to be compared against the first
* @return {Boolean}
*/
module.exports = function scmp (a, b) {
// check that both inputs are buffers
if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) {
throw new Error('Both scmp args must be Buffers')
}
// return early here if buffer lengths are not equal since timingSafeEqual
// will throw if buffer lengths are not equal
if (a.length !== b.length) {
return false
}
// use crypto.timingSafeEqual if available (since Node.js v6.6.0),
// otherwise use our own scmp-internal function.
if (crypto.timingSafeEqual) {
return crypto.timingSafeEqual(a, b)
}
return scmpCompare(a, b)
}