Instance Method
generate(time:range:)
Generates several TOTP’s for a range.
func generate(time: Date, range: Int) -> [String]
Parameters
rangeThe number of codes to generate in both the forward and backward direction. This number must be bigger than 0. For example, if
rangeis2, a total of5codes will be returned: The main code, the two codes prior to the main code and the two codes after the main code.
Return Value
All the generated OTP’s in an array.
Discussion
Note
This function will automatically create the previous and next TOTP’s for a range based on the interval. For example, if the interval is 30 and the range is 2, the result will be calculated for [-1min, -30sec, 0, 30sec, 1min].
Note
This function will automatically wrap the counter by using integer overflow. This might provide some odd behaviour when near the start time or near the max time.