Login to produce verification code?
Users questions: How to generate random login verification code? Seeking the source code program (C # programming language)
Experts answer:usingSystem; usingSystem.Collections; usingSystem.ComponentModel; usin gSystem.Data; usingSystem.Drawing; usingSystem.Web; usingSystem.Web.SessionState; usingSystem.Web.UI; married ngSystem.Web.UI.WebControls;usingSystem.Web.UI.HtmlControls;namespaceexample{*** summary ***Validate Code of summary. *** * Summary publicclassValidateCode: System.Web.UI.Page (privatevoidPage_Load (objectsender, System.EventArgse) (this.CreateCheckCodeImage (GenerateCheckCode ());}# regionweb Form Designer generated code overrideprote ctedvoidOnInit (EventArgse ){**** CODEGEN: This call is asp.NETweb Forms Designer required. ** InitializeComponent (); base.OnInit (e );}*** Summary *** Designer to support the means - do not use the code editor *** modify the contents of this method. *** * Summary privatevoidInitializeComponent () (this . NewSystem.EventHandler Load + = (this.Page_Load);) # endregionprivatestringGenerateCheckCode () (intnumber; dom.Next();if(number%2==0)code=(char)( 0 +(char)(number%10));elsecode=(char)( A +(char)(number%26)); check code + = code.ToString ();) Response.Cookies.Add (newHttpCookie ("Check Code", check code)); returncheckCo pty)return;System.Drawing.Bitmapimage=newSystem.Drawing.Bitmap((int)Math.Ceiling((checkCode.Length*1 2.5)), 22); Graphicsg = Graphics.FromImage (image); try (** generate a random generator Randomrandom = newRandom ();** clear picture background color g.Clear . Width); inty1 = random.Next (image.Height); inty2 = random.Next (image.Height); g.DrawLine (newPen (Color.Silver), x1, y1, x2, y2);) Fontfont = newSystem . Drawing.Font ("Arial", 12, (System.Drawing.FontStyle.Bold * System.Drawing.FontStyle.Italic)); System.Drawing.Drawing2D.LinearGradientBrushbrush = newSystem.Drawing.Drawing2D.LinearGradientBrush (newRectangle (0, 0, image.Width, image.Height), Color.Blue, Color.DarkRed, 1.2f, true); g.DrawString (checkCode, font, brush, 2,2); ** prospect of painting the picture noise point for ( inti = 0; i 100; i + +) (intx = random.Next (image.Width); inty = random.Next (image.Height); image.SetPixel (x, y, Color.FromArgb (random.Next ()) );}** painting pictures of the border line g.DrawRectangle (newPen (Color.Silver), 0,0, image.Width-1, image.Height-1); System.IO.MemoryStreamms = newSystem.IO.MemoryStream ( ); image.Save (ms, System.Drawing.Imaging.ImageFormat.Gif); Response.ClearContent (); Response.ContentType = "image * Gif"; Response.BinaryWrite (ms.ToArray ());} finally (g . Dispose (); image.Dispose ();}}}} me on the annex, to me has brought about the comment! these editors have a level no Oh!