• 要发布游戏啦,平台要 3000个6位不重复的验证码 看我怎么做!!!


            static string guidList = @"D:GuidList.txt";
            static string[] source =null;
            static  string getTheRandomYanZhengMa() {
                string result = "";
                string[] copySource = new List<string>(source).ToArray();
                Random random = new Random();
                for (int i = 0; i < 6; i++) {
                    int length = copySource.Length;
                    int index = random.Next(0, copySource.Length);
                    
                        string temp=copySource[index];
                        result += temp;
                        copySource[index] = copySource[length - 1];
                        copySource[length - 1] = temp;
                        length--;
                }
                return result;
            }
            static void Main()
          {
              source = new string[] { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "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" };  
                    
                using(StreamWriter st=new StreamWriter(guidList))
                {


                    //[] source = {"0","1","2","3","4","5","6","7","8","9","0","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"};  
                    Dictionary<string, bool> datas = new Dictionary<string, bool>();
                    while (true)
                    {
                        if (datas.Count == 3000)
                        {
                            break;
                        }
                        else
                        {
                            string randomText = getTheRandomYanZhengMa();
                            if (!datas.ContainsKey(randomText))
                            {
                                datas.Add(randomText,true);
                            }
                        
                        }
                    
                    }
                    int j = 1;
                    foreach (string key in datas.Keys)
                    {
                        if (j == 3000)
                        {
                            st.Write((j) + " " + key);
                        }
                        else
                        {
                            st.Write((j ) + " " + key + " ");
                        }
                        j++;
                    
                    }

    }

  • 相关阅读:
    如何测得存储空间大小
    打印阿斯科码 和 打印字符
    正常血压
    c语言知识(1)
    子组件和父组件
    RESTful风格API
    django APIview使用
    django 基础
    npm install异常error code EPERM
    springsecurity 多httpsecurity配置
  • 原文地址:https://www.cnblogs.com/zyc-it/p/3574364.html
Copyright © 2020-2023  润新知