'Google
Play App ->
https://play.google.com/store/apps/details?id=com.google.android.apps.authenticator2&hl=es
'Nuget Package -> https://www.nuget.org/packages/GoogleAuthenticator/
Imports Google.Authenticator
Imports System.Net
Imports System.IO
Function RegisterAppFromQrCode() As String
Dim tfa As New TwoFactorAuthenticator()
Dim setupInfo As
SetupCode = tfa.GenerateSetupCode("AppName", "AppSubName", "SuperSecretKeyGoesHere", 300, 300)
Dim qrCodeImageUrl As String
= setupInfo.QrCodeSetupImageUrl
Dim AppKey As String = setupInfo.ManualEntryKey
Dim tClient As
WebClient = New
WebClient
Dim URlImage As
String = qrCodeImageUrl
Dim tImage As Bitmap =
Bitmap.FromStream(New
MemoryStream(tClient.DownloadData(URlImage)))
PictureBox1.Image = tImage '<- app="" code="" qr="" register="" span="" to=""> ->
Return AppKey '<- app="" for="" in="" key="" registered="" span="" validate=""> ->
End Function
Function ValidateVerificationCode(VerificationCode As String)
As Boolean
Dim tfa As New TwoFactorAuthenticator()
Dim isCorrectPIN As
Boolean = False
isCorrectPIN = tfa.ValidateTwoFactorPIN("SuperSecretKeyGoesHere", VerificationCode) '<- code="" from="" qr="" span="" verify=""> ->
Return isCorrectPIN
End Function
Muy buen codigo. Funciono a la primera. Gracias
ResponderEliminar