phpsecYubikey::getYubikeyId
| Versions | |
|---|---|
| b-0.3 | public static phpsecYubikey::getYubikeyId($otp) |
Get the identity of a Yubikey OTP. The identity part is the same for every OTP, and it is the initial 2-16 modhex characters of the OTP. Since the rest of the OTP is always 32 characters, the method to extract the identity is to remove 32 characters from the end and then use the remaining string, which should be 2-16 characters, as the YubiKey identity.
Parameters
string $otp The one time password to get the identity from.
Return value
string Returns the Yubikey identity, or false on failure.
Code
phpsec/
<?php
public static function getYubikeyId($otp) {
if (!self::validOtp($otp)) {
return false;
}
$idLen = strlen($otp) - 32;
return substr($otp, 0, $idLen);
}
?> Copyright (c) 2011, 2012 Audun Larsen.
Drupal theme by Kiwi Themes.
