使用实例:
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { verCodeInfo(); } } /// <summary> /// 验证码生成 /// </summary> private void verCodeInfo() { /*方法1*/ VerCodeHelper v = new VerCodeHelper(); Response.Write("<IMG alt=\"" + "" + "\" src=\"data:image/png;base64," + FileHelper.ImgToBase64String(v.Image) + "\" border=\"0\">"); //固定生成长度的验证码 /*方法1*/ /*方法2*/ string chkCode = VerCodeHelper.MakeCode(5); //根据长度自动生成 MemoryStream ms = VerCodeHelper.CreateCodeImg(chkCode); Response.ClearContent(); Response.ContentType = "image/gif"; Response.BinaryWrite(ms.ToArray()); /*方法2*/ }
类库信息: