Ejemplo n.º 1
0
 internal MvcCaptchaImage(MvcCaptchaOptions options)
 {
     CaptchaOptions = options;
     UniqueId       = Guid.NewGuid().ToString("N");
     _rand          = new Random();
     //Text = GenerateRandomText();
 }
Ejemplo n.º 2
0
        public byte[] CreateCaptcha(string key)
        {
            byte[] ar;
            var    options = new MvcCaptchaOptions();

            options.TextLength = 4;
            var ci = new MvcCaptchaImage(options);

            ci.ResetText();
            using (var b = ci.RenderImage())
            {
                using (var mem = new MemoryStream())
                {
                    b.Save(mem, ImageFormat.Gif);
                    ar = mem.ToArray();
                }
                var    valueKey = GenerateValueKey(key);
                string code     = ci.Text;
                Session.SetString(valueKey, code);
                string str = Session.GetString(valueKey);
            }
            return(ar);
        }