• Home
  • API Documentation
Show / Hide Table of Contents
  • Yort.Otp
    • CounterBasedPasswordGenerator
      • Counter
      • CounterBasedPasswordGenerator
    • IHashAlgorithm
      • ComputeHash
      • Name
    • IOnetimePasswordGenerator
      • GeneratedPassword
      • HashAlgorithm
      • PasswordLength
      • SetSecret
    • MD5HashAlgorithm
      • ComputeHash
      • Name
    • OnetimePasswordAccount
      • Issuer
      • Label
      • Metadata
      • PasswordGenerator
      • Secret
    • OnetimePasswordGeneratorBase
      • Dispose
      • GeneratedPassword
      • HashAlgorithm
      • IsDisposed
      • MovingFactor
      • OnetimePasswordGeneratorBase
      • PasswordLength
      • SetSecret
    • OnetimePasswordGeneratorFactory
      • CreateFactory
      • CreateNewPasswordGenerator
      • FromOtpUrl
      • GetOtpUrl
    • OnetimePasswordSecret
      • FromAscii
      • FromBase32
      • FromHex
      • ToBase32
    • Resource
    • Resource.Attribute
    • Resource.String
      • ApplicationName
      • Hello
    • Sha1HashAlgorithm
      • ComputeHash
      • Name
    • Sha256HashAlgorithm
      • ComputeHash
      • Name
    • Sha512HashAlgorithm
      • ComputeHash
      • Name
    • TimeBasedPasswordGenerator
      • MovingFactor
      • TimeBasedPasswordGenerator
      • TimeInterval
      • Timestamp
      • ValidUntilUtc

Class TimeBasedPasswordGenerator

Used to generate passwords based on a specific time, using the rfc6238 specification for TOTP.

Inheritance
System.Object
OnetimePasswordGeneratorBase
TimeBasedPasswordGenerator
Implements
IOnetimePasswordGenerator
IDisposable
Inherited Members
OnetimePasswordGeneratorBase.HashAlgorithm
OnetimePasswordGeneratorBase.IsDisposed
OnetimePasswordGeneratorBase.PasswordLength
OnetimePasswordGeneratorBase.GeneratedPassword
OnetimePasswordGeneratorBase.Dispose(Boolean)
OnetimePasswordGeneratorBase.SetSecret(Byte[])
OnetimePasswordGeneratorBase.Dispose()
System.Object.ToString()
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
Namespace: Yort.Otp
Assembly: cs.temp.dll.dll
Syntax
public sealed class TimeBasedPasswordGenerator : OnetimePasswordGeneratorBase, IOnetimePasswordGenerator, IDisposable
Remarks

Default values are SHA1, a 30 second time interval and a password length of 6. The current time from the device's clock is used (dynamically) to create the password, so the GeneratedPassword property will change over time.

//Configures a password generator using a base 32 secret (as typically provided by Google).
var passwordGenerator = new TimeBasedPassword();
passwordGenerator.SetSecret(TimeBasedPassword.SecretFromBase32String("JBSWY3DPEHPK3PXP"));
var password = passwordGenerator.GeneratedPassword;

Constructors

Name Description
TimeBasedPasswordGenerator()

Default constructor

TimeBasedPasswordGenerator()

Default constructor

TimeBasedPasswordGenerator(Boolean)

Partial constructor.

TimeBasedPasswordGenerator(Boolean)

Partial constructor.

TimeBasedPasswordGenerator(Boolean, Byte[])

Full constructor, initialises this instance with an already known secret.

TimeBasedPasswordGenerator(Boolean, Byte[])

Full constructor, initialises this instance with an already known secret.

Properties

Name Description
MovingFactor

Uses the Timestamp or current clock time and TimeInterval to generate the counter/moving factor for password generation.

MovingFactor

Uses the Timestamp or current clock time and TimeInterval to generate the counter/moving factor for password generation.

TimeInterval

Sets or returns the amount of time each generated password is valid for. The default is 30 seconds.

TimeInterval

Sets or returns the amount of time each generated password is valid for. The default is 30 seconds.

Timestamp

Sets or returns the date and time to calculate a password for. If null, the current date and time from the device/OS clock is used.

Timestamp

Sets or returns the date and time to calculate a password for. If null, the current date and time from the device/OS clock is used.

ValidUntilUtc

Sets or returns the last second at which the value of GeneratedPassword is valid until.

ValidUntilUtc

Sets or returns the last second at which the value of GeneratedPassword is valid until.

Back to top Copyright (c) 2017 Troy Willmot