phpsecYubikey::validOtp
| Versions | |
|---|---|
| b-0.3 | private static phpsecYubikey::validOtp($otp) |
Validate a string as a one-time-password. A valid OTP should consist of 32-48 printable characters.
Parameters
string $otp String to Validate
Return value
boolean True if the OTP is valid, false on error.
Code
phpsec/
<?php
private static function validOtp($otp) {
$length = strlen($otp);
/* Check length. */
if ($length > 48 || $length < 32) {
return false;
}
/* Check for printable charcters (no whitespace). */
return ctype_graph($otp);
}
?> Copyright (c) 2011, 2012 Audun Larsen.
Drupal theme by Kiwi Themes.
