phpsecYubikey::validOtp

  1. phpsec
    1. dev
    2. a-0.0.3
    3. a-0.0.4
    4. b-0.1
    5. b-0.2
    6. b-0.3
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/phpsec.yubikey.php, line 228

<?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.