Skip to content

Instantly share code, notes, and snippets.

@juucustodio
Last active October 8, 2018 02:35
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 juucustodio/6328883835b3a971ccf41b5828f1f1ee to your computer and use it in GitHub Desktop.
Save juucustodio/6328883835b3a971ccf41b5828f1f1ee to your computer and use it in GitHub Desktop.
Example how to implement a token generator in Xamarin.Forms Applications. - http://julianocustodio.com/token
public void Callback(object state)
{
totp = new Totp(secretKey);
Codigo = totp.ComputeTotp();
var remainingTime = totp.RemainingSeconds();
Segundos = $"00:{remainingTime:00}";
}
protected override void OnAppearing()
{
base.OnAppearing();
timer = new Timer(Callback, null, 0, 1000);
}
protected override void OnDisappearing()
{
timer.Dispose();
base.OnDisappearing();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment