__夏_傷

导航

asp.net生成随机密码

public string RandCode(int n)
        {
            char[] arrChar = new char[]{ 
             'a','b','d','c','e','f','g','h','i','j','k','l','m','n','p','r','q','s','t','u','v','w','z','y','x', 
             '0','1','2','3','4','5','6','7','8','9', 
             'A','B','C','D','E','F','G','H','I','J','K','L','M','N','Q','P','R','T','S','V','U','W','X','Y','Z' 
            };
            StringBuilder num = new StringBuilder();
            Random rnd = new Random(DateTime.Now.Millisecond);
            for (int i = 0; i < n; i++)
            {
                num.Append(arrChar[rnd.Next(0, arrChar.Length)].ToString());
            }
            return num.ToString();
        }

  

posted on 2014-04-02 10:14  Pinson  阅读(246)  评论(0编辑  收藏  举报