public function oath_hotp($key, $counter)
{
if (strlen($key) < 8) {
throw new Exception('Secret key is too short. Must be at least 16 base 32 characters');
}
$bin_counter = pack('N*', 0) . pack('N*', $counter);
// Counter must be 64-bit int
$hash = hash_hmac('sha1', $bin_counter, $key, true);
return str_pad(self::oath_truncate($hash), self::OTPLENGTH, '0', STR_PAD_LEFT);
}