129 foreach (str_split($hash, 2) as $hex)
131 $hmac[] = hexdec($hex);
134 $offset = $hmac[count($hmac) - 1] & 0xf;
135 $code = ($hmac[$offset] & 0x7F) << 24;
136 $code |= ($hmac[$offset + 1] & 0xFF) << 16;
137 $code |= ($hmac[$offset + 2] & 0xFF) << 8;
138 $code |= ($hmac[$offset + 3] & 0xFF);
140 $otp = $code % pow(10, $this->
getDigits());
141 return str_pad($otp, $this->
getDigits(),
'0', STR_PAD_LEFT);
172 if (!is_string($expected))
177 if (!is_string($actual))
182 $lenExpected = strlen($expected);
183 $lenActual = strlen($actual);
185 $status = $lenExpected ^ $lenActual;
186 $len = min($lenExpected, $lenActual);
187 for ($i = 0; $i < $len; $i++)
189 $status |= ord($expected[$i]) ^ ord($actual[$i]);
192 return $status === 0;