Version: 0.18.10.18.20.18.30.19.00.20.00.20.10.20.20.20.30.20.40.21.00.21.10.21.20.21.30.21.40.21.50.21.60.21.70.22.00.23.00.24.00.24.10.24.20.24.30.24.40.24.50.24.60.24.70.24.80.25.00.25.10.25.20.26.00.26.10.26.20.26.30.26.40.26.50.27.00.27.10.27.20.28.00.29.00.29.10.29.20.30.00.30.10.30.21.0.01.1.01.2.01.3.01.4.01.5.01.5.11.5.21.5.31.5.41.5.51.5.62.0.0-beta.02.0.0-beta.12.0.0-beta.22.0.0-beta.32.0.0-beta.42.0.0-beta.52.0.0-beta.62.0.0-beta.72.0.0-beta.82.0.0-beta.92.0.0-beta.102.0.0-beta.112.0.0-beta.122.0.0-beta.132.0.0-beta.142.0.0-beta.152.0.0-beta.162.0.0-beta.172.0.0-beta.182.0.0-beta.192.0.0-beta.202.0.0-beta.212.0.0-beta.222.0.0-beta.232.0.0-beta.242.0.0-beta.252.0.0-beta.262.0.0-beta.272.0.0-beta.282.0.0-beta.292.0.0-beta.302.0.0-beta.312.0.0-beta.322.0.0-beta.332.0.0-beta.342.0.0-beta.352.0.0-beta.362.0.0-beta.372.0.0-beta.382.0.0-beta.392.0.0-beta.402.0.0-beta.412.0.0-beta.422.0.0-beta.432.0.02.0.12.0.22.0.32.0.42.0.52.0.62.0.72.0.82.0.92.0.10-beta12.0.10
/**
* Constant-Time Buffer Compare
* ============================
*
* A constant-time comparison function. This should be used in any security
* sensitive code where leaking timing information may lead to lessened
* security. Note that if the buffers are not equal in length, this function
* loops for the longest buffer, which may not be necessary. Usually this
* function should be used for buffers that would otherwise be equal length,
* such as a hash, particularly Hmacs.
* The algorithm here, which is XORs each byte (or, if undefined, 0) with the
* corresponding other byte, and then ORs that with a running total (d), is
* adapted from here:
* https://groups.google.com/forum/#!topic/keyczar-discuss/VXHsoJSLKhM
*/
'use strict'
const cmp = (buf1, buf2) => {
if (!Buffer.isBuffer(buf1) || !Buffer.isBuffer(buf2)) {
throw new Error('buf1 and buf2 must be buffers')
}
if (buf1.length !== buf2.length) {
return false
let d = 0
for (let i = 0; i < buf1.length; i++) {
const x = buf1[i]
const y = buf2[i]
d |= x ^ y
return d === 0
export { cmp }