verify method

bool verify (String otp, int counter)

Verifies the OTP passed in against the current time OTP.

@param {otp} @type {String} @desc the OTP waiting for checking

@param {counter} @type {int} @desc the OTP HMAC counter

@return {Boolean}

@example TOTP totp = dotp.TOTP('BASE32ENCODEDSECRET'); totp.now(); // => 432143 // Verify for current time totp.verify(432143); // => true // Verify after 30s totp.verify(432143); // => false

Implementation

bool verify(String otp, int counter) {
  String otpCount = this.at(counter);

  if (otp == otpCount) {
    return true;
  }
  return false;
}