You are here

function services_api_key_auth_compare_key in Services API Key Authentication 7

Compare api key.

Parameters

$a string: Token string.

$b string: Token string.

Return value

boolean

1 call to services_api_key_auth_compare_key()
services_api_key_auth_services_authenticate in ./services_api_key_auth.module
Apply authentication rules.

File

./services_api_key_auth.module, line 131
Extend services to allow API key authentication on endpoints.

Code

function services_api_key_auth_compare_key($a, $b) {
  if (strlen($a) !== strlen($b)) {
    return FALSE;
  }
  $result = 0;
  for ($i = 0; $i < strlen($a); $i++) {
    $result |= ord($a[$i]) ^ ord($b[$i]);
  }
  return $result == 0;
}