

If the system clock cannot be used to accurately get the current time, then you can fetch it from an NTP server with the .NtpTimeProvider class, passing in the NTP server hostname you wish you use. If the system clock is reliable, it is reccomended that this provider is used.

Most applications should be able to use the SystemTimeProvider class to provide the time, which gets the time from the system clock. In the example code above, a SystemTimeProvider is used, but this is not the only option.

When verifying user submitted codes with a DefaultCodeVerifier, a TimeProvider is needed to get the current time (unix) time. Once again, the number of digits must be the same as what was specified when the QR code for the secret was created. The above generator will generate codes of 4 digits, using the SHA1 algorithm. CodeGenerator codeGenerator = new DefaultCodeGenerator( HashingAlgorithm.
