You are here

protected static function LockrAes128CtrSha256KeyWrapper::hashEquals in Lockr 7.2

1 call to LockrAes128CtrSha256KeyWrapper::hashEquals()
LockrAes128CtrSha256KeyWrapper::decrypt in vendor/lockr/lockr-client/src/KeyWrapper/LockrAes128CtrSha256KeyWrapper.php
Decrypt the given ciphertext using encoded.

File

vendor/lockr/lockr-client/src/KeyWrapper/LockrAes128CtrSha256KeyWrapper.php, line 117

Class

LockrAes128CtrSha256KeyWrapper

Namespace

Lockr\KeyWrapper

Code

protected static function hashEquals($left, $right) {
  if (function_exists('hash_equals')) {
    return hash_equals($left, $right);
  }
  $ret = 0;
  if (strlen($left) !== strlen($right)) {
    $right = $left;
    $ret = 1;
  }
  $res = $left ^ $right;
  for ($i = strlen($res) - 1; $i >= 0; --$i) {
    $ret |= ord($res[$i]);
  }
  return !$ret;
}