<?php /** * You can request your API key from: * https://upgrade.yubico.com/getapikey/ * * Usage: * php test.php [OTP from the Yubikey] */ require_once 'vendor/autoload.php'; $apiKey = 'dGVzdGluZzEyMzQ1Njc4OTA='; $clientId = '12345'; $v = new \Yubikey\Validate($apiKey, $clientId); if (isset($_SERVER['argv'][1])) { $result = $v->check($_SERVER['argv'][1]); print_r($result); var_export($result->success()); } else { echo "No key value specified\n\n"; }
/** * Test that an exception is thrown when the API is invalid (null or empty) * @covers \Yubikey\Validate::generateSignature * @expectedException \InvalidArgumentException */ public function testSignatureGenerateNoApiKey() { $key = null; $data = array('foo' => 'bar'); $validate = new \Yubikey\Validate($key, $this->clientId); $hash = preg_replace('/\\+/', '%2B', base64_encode(hash_hmac('sha1', http_build_query($data), $key, true))); $signature = $validate->generateSignature($data); }