public static bool IsValidSecret(string secret, AuthenticatorType type)
        {
            if (String.IsNullOrEmpty(secret))
            {
                return(false);
            }

            if (type.IsHmacBased())
            {
                try
                {
                    var output = Base32.Rfc4648.Decode(secret);
                    return(output.Length > 0);
                }
                catch
                {
                    return(false);
                }
            }

            if (type == AuthenticatorType.MobileOtp)
            {
                return(secret.Length >= MobileOtp.SecretMinLength);
            }

            throw new ArgumentOutOfRangeException(nameof(type));
        }
        public static bool IsValidSecret(string secret, AuthenticatorType type)
        {
            if (String.IsNullOrEmpty(secret))
            {
                return(false);
            }

            if (type.IsHmacBased())
            {
                try
                {
                    return(Base32Encoding.ToBytes(secret).Length > 0);
                }
                catch (ArgumentException)
                {
                    return(false);
                }
            }

            if (type == AuthenticatorType.MobileOtp)
            {
                return(secret.Length >= MobileOtp.SecretMinLength);
            }

            throw new ArgumentOutOfRangeException(nameof(type));
        }
        public static string CleanSecret(string input, AuthenticatorType type)
        {
            if (type.IsHmacBased())
            {
                input = input.ToUpper();
            }

            input = input.Replace(" ", "");
            input = input.Replace("-", "");

            return(input);
        }