Esempio n. 1
0
 public static string GetCaptchaBase64(
     int length = 5,
     CaptchaFormat captchaFormat = CaptchaFormat.Numeric,
     int width  = 120,
     int height = 50)
 {
     return(Convert.ToBase64String(CaptchaManager.GetCaptchaByteArray(length, captchaFormat, width, height)));
 }
Esempio n. 2
0
        public static Image GetCaptchaImage(
            int length = 5,
            CaptchaFormat captchaFormat = CaptchaFormat.Numeric,
            int width  = 120,
            int height = 50)
        {
            CaptchaImage captchaImage = new CaptchaImage(length, captchaFormat, Color.Transparent, width, height);


            SessionManager.Add("__Captcha__", (object)captchaImage);
            return((Image)captchaImage.Image);
        }
Esempio n. 3
0
        public static byte[] GetCaptchaByteArray(
            int length = 5,
            CaptchaFormat captchaFormat = CaptchaFormat.Numeric,
            int width  = 120,
            int height = 50)
        {
            Image        captchaImage = CaptchaManager.GetCaptchaImage(5, Enums.CaptchaFormat.Numeric, 120, 50);
            MemoryStream memoryStream = new MemoryStream();

            captchaImage.Save((Stream)memoryStream, ImageFormat.Png);
            return(memoryStream.ToArray());
        }