C# 登陆账号密码验证码(不是很完善需要修改)

C# 登陆账号密码验证码(不是很完善需要修改),第1张

概述设置密码!  Console.WriteLine("\t\t\t-----用户设置界面-------");             string account = null;             while (true)             {                 Console.WriteLine("请设置账号:");                 Console.Wri

设置密码!

 Console.Writeline("\t\t\t-----用户设置界面-------");

            string account = null;

            while (true)

            {

                Console.Writeline("请设置账号:");

                Console.Writeline("规则:只能包含数字。");

              account = Console.Readline();

                string pra = @"^\d*$";

                bool a = Regex.IsMatch(account,pra);

                if (a == true)

                {

                    Console.Writeline("账号符合要求");

                    break;

                }

                Console.Clear();

            }

            string passWord = null;

            while (true)

            {

                Console.Writeline("请设置登录密码:");

                Console.Writeline("规则:只能包含以下字符1、含有大写字母。2、含有小写字母。3、含有数字。");

                int count = 0;

                passWord= Console.Readline();

                string b = @"[a-z]";

                string c = @"[0-9]";

                string d = @"[A-Z]";

                string e = @"[!#$_*~]";

                bool bb = Regex.IsMatch(passWord,b);

                bool cc = Regex.IsMatch(passWord,c);

                bool dd = Regex.IsMatch(passWord,d);

                bool ee = Regex.IsMatch(passWord,e);

                if (bb==true){count++;}

                if (cc == true) { count++; }

                if (dd == true) { count++; }

                if (ee== true) { count++; }

                if (count>=3)

                {

                    Console.Writeline("密码符合要求");

                    break;

                }

                Console.Clear();

            }

            Console.Clear();

            Console.Writeline("\t\t\t---------用户登录密码----------");

            while (true)

            {

                Console.Writeline("请输入账号:");

                string user = Console.Readline();

                Console.Writeline("请输入密码:");

                string pass = Console.Readline();

                if (user == account || pass == passWord)

                {

                   aa: Console.Writeline("请输入验证码")

 

 Random verification = new Random();

                    int num = verification.Next(1000,9999);

                    Console.Writeline(num);

                    int userin = int.Parse(Console.Readline());

                    if (userin!= num)

                    {

                        goto aa;

                    }

                    Console.Writeline("恭喜成功登录");

                    break;

                }

                Console.Clear();

                Console.Writeline("---------用户登录密码----------");

                Console.Writeline("账号或密码不正确。");

            }

            Console.ReadKey();

总结

以上是内存溢出为你收集整理的C# 登陆账号密码验证码(不是很完善需要修改)全部内容,希望文章能够帮你解决C# 登陆账号密码验证码(不是很完善需要修改)所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/langs/1225256.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-05
下一篇 2022-06-05

发表评论

登录后才能评论

评论列表(0条)

保存