public class TotpCounter extends Object
The 64-bit counter assumes the value 0 at a predefined point in time and periodically
increments its value by one periodically.
The value V of the counter at time instant T is:
V = (T - T0) / TimeStepwhere
T0 is the earliest time instant at which the counter assumes the value 0,
and TimeStep is the duration of time for which the values of the counter remain constant.
Note: All time instants are in seconds since UNIX epoch, and all time durations are in seconds.
Note: All time instants must be non-negative.
Thread-safety: Instances of this class are immutable and are thus thread-safe. Source: http://code.google.com/p/google-authenticator License: ASL 2.0
| Constructor and Description |
|---|
TotpCounter(long timeStep)
Constructs a new
TotpCounter that starts with the value 0 at time instant
0 (seconds since UNIX epoch) and increments its value with the specified frequency. |
TotpCounter(long timeStep,
long startTime)
Constructs a new
TotpCounter that starts with the value 0 at the specified
time and increments its value with the specified frequency. |
| Modifier and Type | Method and Description |
|---|---|
long |
getStartTime()
Gets the earliest time instant at which this counter assumes the value
0. |
long |
getTimeStep()
Gets the frequency with which the value of this counter changes.
|
long |
getValueAtTime(long time)
Gets the value of this counter at the specified time.
|
long |
getValueStartTime(long value)
Gets the time when the counter assumes the specified value.
|
public TotpCounter(long timeStep)
TotpCounter that starts with the value 0 at time instant
0 (seconds since UNIX epoch) and increments its value with the specified frequency.timeStep - interval of time (seconds) between successive changes of this counter's value.public TotpCounter(long timeStep,
long startTime)
TotpCounter that starts with the value 0 at the specified
time and increments its value with the specified frequency.timeStep - interval of time (seconds) between successive changes of this counter's value.startTime - the earliest time instant (seconds since UNIX epoch) at which this counter
assumes the value 0.public long getTimeStep()
public long getStartTime()
0.public long getValueAtTime(long time)
time - time instant (seconds since UNIX epoch) for which to obtain the value.time.public long getValueStartTime(long value)
value - value.Copyright © 2019. All Rights Reserved.