Skip to content
Discussion options

You must be logged in to vote

From a mechanical perspective: generate the expected code, then check if the provided code matches the expected code. For example:

if (providedOneTimePasswordString.equals(totp.generateOneTimePasswordString(key, timestamp)) {
  // Success!
}

…but please note that there are lots of other factors to consider! How much clock drift will you allow? How many times is a user allowed to retry? What happens when a user exceeds that limit? These (and other) considerations are discussed in greater detail in:

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by jchambers
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants