Dynamic generation verification code picture

xiaoxiao2021-03-06  40

using System; using System.IO; using System.Collections; using System.ComponentModel; using System.Data; using System.Drawing; using System.Drawing.Imaging; using System.Web; using System.Web.SessionState; using System. Web.ui; using system.web.ui.webcontrols; using system.web.ui.htmlcontrols;

A summary description of Namespace vildate {///

/// yZGIF. /// public class yzgif: system.web.ui.page {private sender, system.eventargs e) {string vnum = ""; vnum = this.rndnum (4); session [" VNUM "] = vnum; this.validatacode (vnum);

#Region Web Form Designer Generated CodeOverride Protected Void OnNit (Eventargs E) {//// Codegen: This call is required for the ASP.NET Web Form Designer. //Initializecomponent();Base.oninit (E);

///

/// Designer supports the required method - do not use the code editor to modify the // / this method. /// private () {this.load = new system.eventhandler (this.page_load);} # endregion

public void ValidataCode (string str) {System.Drawing.Bitmap Img; Graphics g; MemoryStream ms; int gheight = str.Length * 11; Img = new Bitmap (gheight, 20); g = Graphics.FromImage (Img); SolidBrush SB = new solidbrush; font ft = new font ("arial", 10); g.drawstring (Str, FT, SB, 3, 3); ms = new memoryStream (); img.save (MS Imageformat.png); response.clearContent (); response.contenttype = "image / png"; response.binarywrite (ms.toarray ()); g.dispose (); img.dispose (); response.end () } public string rndnum = ""; random rnd = new random (); string vchar = "0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, S, D, F, G, H, J, K, L, Q, W, E, R, T, Y, U, I, O, P, Z, X, C, V, B, N, M, Q, W, E, R, T, Y, U, I, O, P, A, S, D, F, G, H, J, K, L, Z, X, C, V, B, N, M "; string [] vc = vchar.split (','); for (int K = 0; k Verification Code:

转载请注明原文地址:https://www.9cbs.com/read-71180.html

New Post(0)