src/encryption.js
function constantTimeCompare (val1, val2) {
  let sentinel

  if (val1.length !== val2.length) return false

  for (let i = 0, len = val1.length; i < len; i++) {
    sentinel |= val1.charCodeAt(i) ^ val2.charCodeAt(i)
  }

  return sentinel === 0
}
function constantTimeCompare (val1, val2) {
  let sentinel

  if (val1.length !== val2.length) return false

  for (let i = 0, len = val1.length; i < len; i++) {
    sentinel |= val1.charCodeAt(i) ^ val2.charCodeAt(i)
  }

  return sentinel === 0
}
function constantTimeCompare ( val1 , val2 ) { let sentinel if ( val1 . length !== val2 . length ) return false for ( let i = 0 , len = val1 . length ; i < len ; i ++ ) { sentinel |= val1 . charCodeAt ( i ) ^ val2 . charCodeAt ( i ) } return sentinel === 0 }
Ensures the encrypted payload has not been tampered with.
@param {string} val1 - Hash to compare
@param {string} val2 - Hash to compare to
@return {boolean} Whether it is valid
Ensures the encrypted payload has not been tampered with .