资源简介

ASP.NET下Sina跟QQ的登录接口调用源代码OAuth2.0版 文章链接 www.cnblogs.com/eyu/archive/2012/03/22/sina_qq_oauth2_dnt.html

资源截图

代码片段和文件信息

using System;
using System.Text;

namespace Common
{
    public sealed class RandomText
    {
        static readonly string[] source ={“2““3““4““5““6““7““8““9“
            “a““b““c““d““e““f““h““j““k““m““n““p““r““s““t““u““v““w““x““y““z“
            “A““B““C““D““E““F““G““H““J““K““M““N““P““Q““R““S““T““U““V““W““X““Y““Z“};

        private static Random _random;

        static RandomText()
        {
            _random = new Random(Environment.TickCount);
        }

        public static int Number(int minValue int maxValue)
        {
            return _random.Next(minValue maxValue);
        }

        public static string String(int length)
        {
            StringBuilder s = new StringBuilder();

            for (int i = 0; i < length; i++)
            {
                int index = Number(0 source.Length - 1);
                s.Append(source[index]);
            }

            return s.ToString();
        }

        public static string CharOnly(int length)
        {
            StringBuilder s = new StringBuilder();

            for (int i = 0; i < length; i++)
            {
                int c = _random.Next(97 123);

                if (_random.Next() % 2 == 0)
                    c -= 32;

                s.Append(Convert.ToChar(c));
            }

            return s.ToString();
        }
    }
}

评论

共有 条评论