Example #1
0
        public static bool CheckValidate(string key, string code)
        {
            string ogKey = GetOrgianalKey(key);
            var    d     = new Google.Authenticator.TwoFactorAuthenticator();

            return(d.ValidateTwoFactorPIN(ogKey, code));
        }
Example #2
0
        public static string GetRandomSecrect()
        {
            string key    = getStr(10);
            var    d      = new Google.Authenticator.TwoFactorAuthenticator();
            var    bytes  = Encoding.Default.GetBytes(key);
            string newKey = Base32.ToString(bytes);

            return(newKey);
        }
Example #3
0
        public static SecondFactorAuthSetupCode GenerateSetupCode(string issuer, string username, string secretKey, int qrCodeWidth, int qrCodeHeigt)
        {
            Google.Authenticator.TwoFactorAuthenticator tfa = new Google.Authenticator.TwoFactorAuthenticator();
            Google.Authenticator.SetupCode setupInfo        = tfa.GenerateSetupCode(issuer, username, secretKey, qrCodeWidth, qrCodeHeigt);

            SecondFactorAuthSetupCode setupCode = new SecondFactorAuthSetupCode()
            {
                QrCodeImageUrl = setupInfo.QrCodeSetupImageUrl,
                SetupCode      = setupInfo.ManualEntryKey,
            };

            return(setupCode);
        }
Example #4
0
 public static bool ValidatePIN(string secretKey, string pin)
 {
     Google.Authenticator.TwoFactorAuthenticator tfa = new Google.Authenticator.TwoFactorAuthenticator();
     return(tfa.ValidateTwoFactorPIN(secretKey, pin));
 }