Skip to content

Instantly share code, notes, and snippets.

@asaph
Created April 25, 2016 03:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save asaph/df0c6487b3ec83a3c9ba1cfd6040bb1e to your computer and use it in GitHub Desktop.
Save asaph/df0c6487b3ec83a3c9ba1cfd6040bb1e to your computer and use it in GitHub Desktop.
Generate 6 digit 2fa codes in sync with Google Authenticator
String secretKey = "quu6 ea2g horg md22 sn2y ku6v kisc kyag";
String lastCode = null;
while (true) {
String code = getTOTPCode(secretKey);
if (!code.equals(lastCode)) {
// output a new 6 digit code
System.out.println(code);
}
lastCode = code;
try {
Thread.sleep(1000);
} catch (InterruptedException e) {};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment