zoukankan      html  css  js  c++  java
  • c#验证码

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    
    namespace 验证码字符串做法
    {
        class Program
        {
            static void Main(string[] args)
            {
                //定义一组字符串
                string[] s= new string[62]
                {"0","1","2","3","4","5","6","7","8","9",
                    "a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s",
                 "t","u","v","w","x","y","z",
                    "A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q",
                "R","S","T","U","V","W","X","Y","Z"
                };
                string a="";//定义一个a的字符变量,值为空
                Random ran = new Random();
                for (int i = 0; i < 4;i++ )
                {
                    int suijishu = ran.Next(0, 62);
                    a+= s[suijishu];//将随机产生的四个字符连成一个字符串表示验证码
                }
                Console.WriteLine("验证码:"+a);
                string b = a.ToUpper();//后台执行把所得的字符串全部转换为大写
                Console.Write("请输入验证码:");
                string r = Console.ReadLine();
                string q = r.ToUpper();//将用户输入的字符串全部转换为大写
                if (q == b)
                {
                    Console.WriteLine("验证成功!");
                }
                else
                {
                    Console.WriteLine("输入错误!");
                }
                
    
    
                Console.ReadLine();
            }
        }
    }
  • 相关阅读:
    mogodb学习
    rman list incarnation
    Java创建对象的四种方式
    JAVA 8 函数式接口--Consumer
    Linux中VIM的使用
    JRE 和 JDK 的区别
    tengine-2.3.1 增加ngx_http_upstream_check_module 模块
    k8s的coredns 增加外部dns解析记录
    Dockerfile的CMD总结
    redis数据转移随笔
  • 原文地址:https://www.cnblogs.com/fengsantianya/p/5511272.html
Copyright © 2011-2022 走看看