可按Ctrl+D收藏 蚂蚁资源网

蚂蚁资源网

验证码源码(搭建验证码平台源码分享)

  • 时间:2021-02-11 17:10 编辑:舞田奈美 来源:蚂蚁资源 阅读:130
  • 扫一扫,手机访问
摘要:大家好,今天给大家介绍关于验证码源码(搭建验证码平台源码分享)的相关内容,详细讲解验证码的源代码,jsp的.NET的最好全有,php的验证码代码,跪求。。。。制作用户登录验证码代码等,希望可以帮助到您。
验证码的源代码,jsp的.NET的最好全有,<%@page contentType="image/jpeg" %> ----------------页面包S0636;导入java.io. *;导入java.util。 *;导入javax.imageio。 *;导入java.awt。 *;导入java.awt.image。 *;公共类IMG001 {public img001(){}私人char maptable [] = {'a','b','c','d','e','f','g','h','g','h','我','j','k','l','m','n','o','p','q','r','s','t','你','你' ,'v','w','x','y','z','0','1','2','3','4','5','6',' 7','8','9'}; //设置一个数组,验证码的内容来自此数组公共字符串Getcenure(int宽度,int height,OutputStream OS){if(width <= 0)宽度= 60; //删除错误的错误(高度<= 0)高度= 20; //防止错误的错误//设置缓冲区映像对象bufferedimage映像= new bufferedimage(宽度,高度,bufferedimage.type_int_rgb);//设置图像对象图形g =映像.Graphics(); //设置背景颜色G.SetColor(新颜色(0xDCDCDC)); G.FillRect(0,0,宽度,高度); //打包当前图片//设置颜色g.setcolor(color.black); G.DrawRect(0,0,宽度-1,高度-1); //设置字符串字符串strnsure =“”; // 4表示我的验证码为6位(int i = 0; i <6; ++ i){scrensure + = maptable [(int))]; g.setcolor(color.ble); g.setfont(新字体(“Atlantic Inline”,Font.Plain,18)); //打印第一验证码字符串str = stretsure.substring(0,1); g.drawstring(str,8,17); //团队两位验证码str = stretsure.substring(1,2); G.Drawstring(STR,20,15); //打印第三验证码str = stretsure.substring(2,3); g.drawstring(str,35,18); //打印foUR位验证码str = stretsure.substring(3,4); G.Drawstring(STR,45,15); //开发5位验证码str = stretsure.substring(4,5); g.drawstring(str,55,18); //打印6位验证码str = stretsure.substring(5,6); g.drawstring(str,65,16); //设置干扰点20个随机rand = new randul(); for(int i = 0; i <20; i ++){int x = rand.nextint(宽度); int y = rand.nextint(高度); G.DrawOval(x,y,1,1);} //打印出g.dispose()的图片;尝试{imageio。写(图像,“JPEG”,OS);捕获(IoException e){return“”;}}} - 程序 -
php的验证码代码, randcode = start(substr(rand(rand()),0,$ this-> num);返回$ this-> randcode;} / ** *会话的值* ** /私有函数russe(){ $ _session ['code'] = $ this-> randcode;} / ** *生成验证图片*** /私有函数create_image(){$ this-> imageCreate($ this->宽度,$ this-> height) ; Imagecolorallocate($ this-> im,rand(50,60),rand(230,250));返回$ this-> im;} / ** *生成干扰素* ** / private函数create_interferon(){for( $ i = 0; $ i <$this->干扰素; $ i ++){$ Infcolor = Imagecolorallocate($ this-> im,rand(0,255),rand(0,255)); imagesetpixel($ this-> im,rand( 0,80),Rand(0,20),$ Infcolor);} / ** *生成干扰线* ** /私有函数create_line(){for($ j = 0; $ j <$this->行; $ j ++){$ linecolor = imagecolorlocate($ this-> im,rand(0,255),兰特(0,255),兰特(0,255)); Imageline($ this-> im,rand(0,8),rand(0,20),rand(0,20),$ linecolor);} / ** *写字符* ** / private函数read_text() {for($ i = 0; $ i <$this-> num; $ i ++){$ textcolor = imagecolorlocate($ this-> im,rand(0,100),rand(0,100)); $ x = rand($ this-> width / $ this-> num * $ i),($ this-> width / $ this-> num)*($ i + 1)-10); $ y = rand(2,$这个 - >高度-13); Imagechar($ this-> im,rand(4,5),$ x,$ y,$ this-> randcode [$ i],$ textcolor);} / ** *输出验证码图片* ** / public函数show_image(){$ this-> session_star(); $ this-> conten_type(); $ this-> random(); $以下 - >性能(); $ this-> create_image(); $ this-> create_interferon(); $这个 - >create_line(); $以下 - > read_text(); imagepng($ this-> imimagesdestroy($ this-> im); $ va = new validate(); $ va-> show_image();?>
跪求。。。。制作用户登录验证码代码,首先,生成验证码的函数'-------------------获取验证码------------------ - -----函数getValidateCode()随机化定时器'生成一个随机数getvalidateCode = left(int(rnd * 9998)+1000,4)如果len(getvalidatecode)> 4然后getvalidatecode = len(getvalidatecode&9999,4)结束ifend函数'------------------------------------------呼叫方法(下面下面):<%ValidateCode=GetValidateCode()'将获取的验证码赋值给ValidateCode%>“”> 舞田奈美)

以上就是关于**验证码源码,搭建验证码平台源码分享**的全部内容,了解更多请关注蚂蚁资源网。
  • 全部评论(3)
  • 万岳科技
  • 求ASP验证码代码,<%Option Explicit ' 显示声明Class Com_GifCode_ClassPublic Noisy, Count, Width, Height, Angle, Offset, BorderPrivate Graph(), Margin(3)Private Sub Class_Initialize()RandomizeNoisy = 6 ' 干扰点出现的概率Count = 4 ' 字符数量Width = 80 ' 图片宽度Height = 20 ' 图片高度Angle = 2 ' 角度随机变化量Offset = 20 ' 偏移随机变化量Border = 1 ' 边框大小End SubPublic Function Create()Const cCharSet = "123456789"Dim i, x, yDim vValidCode : vValidCode = ""Dim vIndexReDim Graph(Width-1, Height-1)For i = 0 To Count - 1vIndex = Int(Rnd * Len(cCharSet))vValidCode = vValidCode + Mid(cCharSet, vIndex+1 , 1)SetDraw vIndex, iNextCreate = vValidCodeEnd FunctionSub SetDot(pX, pY)If pX * (Width-pX-1) >= 0 And pY * (Height-pY-1) >= 0 ThenGraph(pX, pY) = 1End IfEnd SubPublic Sub SetDraw(pIndex, pNumber)' 字符数据Dim DotData(8)DotData(0) = Array(30, 15, 50, 1, 50, 100)DotData(1) = Array(1 ,34 ,30 ,1 ,71, 1, 100, 34, 1, 100, 93, 100, 100, 86)DotData(2) = Array(1, 1, 100, 1, 42, 42, 100, 70, 50, 100, 1, 70)DotData(3) = Array(100, 73, 6, 73, 75, 6, 75, 100)DotData(4) = Array(100, 1, 1, 1, 1, 50, 50, 35, 100, 55, 100, 80, 50, 100, 1, 95)DotData(5) = Array(100, 20, 70, 1, 20, 1, 1, 30, 1, 80, 30, 100, 70, 100, 100, 80, 100, 60, 70, 50, 30, 50, 1, 60)DotData(6) = Array(6, 26, 6, 6, 100, 6, 53, 100)DotData(7) = Array(100, 30, 100, 20, 70, 1, 30, 1, 1, 20, 1, 30, 100, 70, 100, 80, 70, 100, 30, 100, 1, 80, 1, 70, 100, 30)DotData(8) = Array(1, 80, 30, 100, 80, 100, 100, 70, 100, 20, 70, 1, 30, 1, 1, 20, 1, 40, 30, 50, 70, 50, 100, 40)Dim vExtent : vExtent = Width / CountMargin(0) = Border + vExtent * (Rnd * Offset) / 100 + Margin(1)Margin(1) = vExtent * (pNumber + 1) - Border - vExtent * (Rnd * Offset) / 100Margin(2) = Border + Height * (Rnd * Offset) / 100Margin(3) = Height - Border - Height * (Rnd * Offset) / 100Dim vStartX, vEndX, vStartY, vEndYDim vWidth, vHeight, vDX, vDY, vDeltaTDim vAngle, vLengthvWidth = Int(Margin(1) - Margin(0))vHeight = Int(Margin(3) - Margin(2))' 起始坐标vStartX = Int((DotData(pIndex)(0)-1) * vWidth / 100)vStartY = Int((DotData(pIndex)(1)-1) * vHeight / 100)Dim i, jFor i = 1 To UBound(DotData(pIndex), 1)/2If DotData(pIndex)(2*i-2) <> 0 And DotData(pIndex)(2*i) <> 0 Then' 终点坐标vEndX = (DotData(pIndex)(2*i)-1) * vWidth / 100vEndY = (DotData(pIndex)(2*i+1)-1) * vHeight / 100' 横向差距vDX = vEndX - vStartX' 纵向差距vDY = vEndY - vStartY' 倾斜角度If vDX = 0 ThenvAngle = Sgn(vDY) * 3.14/2ElsevAngle = Atn(vDY / vDX)End If' 两坐标距离If Sin(vAngle) = 0 ThenvLength = vDXElsevLength = vDY / Sin(vAngle)End If' 随机转动角度vAngle = vAngle + (Rnd - 0.5) * 2 * Angle * 3.14 * 2 / 100vDX = Int(Cos(vAngle) * vLength)vDY = Int(Sin(vAngle) * vLength)If Abs(vDX) > Abs(vDY) Then vDeltaT = Abs(vDX) Else vDeltaT = Abs(vDY)For j = 1 To vDeltaTSetDot Margin(0) + vStartX + j * vDX / vDeltaT, Margin(2) + vStartY + j * vDY / vDeltaTNextvStartX = vStartX + vDXvStartY = vStartY + vDYEnd IfNextEnd SubPublic Sub Output()Response.Expires = -9999Response.AddHeader "pragma", "no-cache"Response.AddHeader "cache-ctrol", "no-cache"Response.ContentType = "image/gif"' 文件类型Response.BinaryWrite ChrB(Asc("G")) & ChrB(Asc("I")) & ChrB(Asc("F"))' 版本信息Response.BinaryWrite ChrB(Asc("8")) & ChrB(Asc("9")) & ChrB(Asc("a"))' 逻辑屏幕宽度Response.BinaryWrite ChrB(Width Mod 256) & ChrB((Width \ 256) Mod 256)' 逻辑屏幕高度Response.BinaryWrite ChrB(Height Mod 256) & ChrB((Height \ 256) Mod 256)Response.BinaryWrite ChrB(128) & ChrB(0) & ChrB(0)' 全局颜色列表Response.BinaryWrite ChrB(255) & ChrB(255) & ChrB(255)Response.BinaryWrite ChrB(0) & ChrB(85) & ChrB(255)' 图象标识符Response.BinaryWrite ChrB(Asc(","))Response.BinaryWrite ChrB(0) & ChrB(0) & ChrB(0) & ChrB(0)' 图象宽度Response.BinaryWrite ChrB(Width Mod 256) & ChrB((Width \ 256) Mod 256)' 图象高度Response.BinaryWrite ChrB(Height Mod 256) & ChrB((Height \ 256) Mod 256)Response.BinaryWrite ChrB(0) & ChrB(7) & ChrB(255)Dim x, y, i : i = 0For y = 0 To Height - 1For x = 0 To Width - 1If Rnd < Noisy / 100 ThenResponse.BinaryWrite ChrB(1-Graph(x, y))ElseIf x * (x-Width) = 0 or y * (y-Height) = 0 ThenResponse.BinaryWrite ChrB(Graph(x, y))ElseIf Graph(x-1, y) = 1 or Graph(x, y) or Graph(x, y-1) = 1 ThenResponse.BinaryWrite ChrB(1)ElseResponse.BinaryWrite ChrB(0)End IfEnd IfEnd IfIf (y * Width + x + 1) Mod 126 = 0 ThenResponse.BinaryWrite ChrB(128)i = i + 1End IfIf (y * Width + x + i + 1) Mod 255 = 0 ThenIf (Width*Height - y * Width - x - 1) > 255 ThenResponse.BinaryWrite ChrB(255)ElseResponse.BinaryWrite ChrB(Width * Height Mod 255)End IfEnd IfNextNextResponse.BinaryWrite ChrB(128) & ChrB(0) & ChrB(129) & ChrB(0) & ChrB(59)End SubEnd ClassDim mCodeSet mCode = New Com_GifCode_ClassSession("GetCode") = mCode.Create()mCode.Output()Set mCode = Nothing%>调用方法:保存以上代码为checkGIF.asp 程序代码<input name="CheckCode" type="text" class="InputTxtLogin" id="CheckCode" onMouseOver="this.style.background='#ffffff';" onMouseOut="this.style.background='#f3f3f3'" size="4" maxlength="4"><img src="checkGIF.asp">
  • 2021-02-11 17:10:05
  • LouisWang
  • 我举个.net的验证码产生的代码,你可以看看: 新建yanzhengma1.aspx.cs文件,写入一下代码: using System; using System.Collections; using System.Configuration; using System.Data; using System.Linq; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.HtmlControls; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Xml.Linq; using System.Drawing; public partial class yanzhengma : System.Web.UI.Page { // private System.IO.MemoryStream ms = newSystem.IO.MemoryStream(); protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { yanzhengmayzm = new yanzhengma(); Session["code1"] = yzm.CreateImage(5, ValidType.Numeric); } } /// <summary> /// 验证码的类型 /// </summary> public enum ValidType { /// <summary> /// 只有数字 /// </summary> Numeric, /// <summary> /// 数字和英文字符 /// </summary> NumericAndEnglishChar, /// <summary> /// 中文字符 /// </summary> ChineseChar } /// <summary> /// 生成一个随机文字图片,保存在 Session["code1"] /// </summary> /// <param name="count">图片中字的个数</param> /// <returns>生成的文字</returns> public string CreateImage(int count, ValidType type) { string ValidCode = GenCode(count,type); switch (type) { caseValidType.Numeric: CreateCheckCodeImage(ValidCode, 13.5); break; caseValidType.NumericAndEnglishChar: CreateCheckCodeImage(ValidCode, 14); break; caseValidType.ChineseChar: CreateCheckCodeImage(ValidCode, 22.5); break; default: break; } return ValidCode; } /// <summary> /// 产生随机字符串 /// </summary> /// <param name="num">随机出几个字符</param> /// <returns>随机出的字符串</returns> private string GenCode(int num, ValidType type) { string str; switch (type) { caseValidType.Numeric: str = "0123456789"; break; caseValidType.NumericAndEnglishChar: str ="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; break; caseValidType.ChineseChar: //常用498个汉字 写不完了,字数限制,你可以留下邮箱我给你完整的参考代码
  • 2021-02-11 17:10:05
  • 亚亚
  • #region 生成随机数 public static string RandomNum(int n) { string strchar = "0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z"; string[] VcArray = strchar.Split(','); string VNum = ""; int temp = -1; Random rand = new Random(); for (int i = 1; i < n + 1; i++) { if (temp != -1) { rand = new Random(i * temp * unchecked((int)DateTime.Now.Ticks)); } int t = rand.Next(61); if (temp != -1 && temp == t) { return RandomNum(n); } temp = t; VNum += VcArray[t]; } return VNum; } #endregion #region 验证码图片 public static void CheckCodes(string M_CheckCode) { Random rand = new Random(); int iwidth = (int)(M_CheckCode.Length * 15); System.Drawing.Bitmap image = new System.Drawing.Bitmap(iwidth, 22); Graphics g = Graphics.FromImage(image); g.Clear(Color.White); //画图片的背景噪音线20条 for (int i = 0; i < 20; i++) { int x1 = rand.Next(image.Width); int x2 = rand.Next(image.Width); int y1 = rand.Next(image.Height); int y2 = rand.Next(image.Height); g.DrawLine(new Pen(Color.Silver), x1, x2, y1, y2); } //定义颜色 Color[] c = { Color.Black, Color.Red, Color.DarkBlue, Color.Green, Color.Orange, Color.Brown, Color.DarkCyan, Color.Purple, Color.YellowGreen }; //定义字体 string[] font = { "Verdana", "Microsoft Sans Serif", "Comic Sans MS", "Arial", "宋体", "新宋体" }; //随机输出噪点 for (int i = 0; i < 50; i++) { int x = rand.Next(image.Width); int y = rand.Next(image.Height); g.DrawRectangle(new Pen(Color.LightGray, 0), x, y, 1, 1); } //输出不同字体和颜色的验证码字符 for (int i = 0; i < M_CheckCode.Length; i++) { int cindex = rand.Next(7); int findex = rand.Next(6); Font f = new System.Drawing.Font(font[findex], 12, System.Drawing.FontStyle.Bold); Brush b = new System.Drawing.SolidBrush(c[cindex]); int ii = 4; if ((i + 1) % 2 == 0) { ii = 2; } g.DrawString(M_CheckCode.Substring(i, 1), f, b, 3 + (i * 12), ii); } //画一个边框 g.DrawRectangle(new Pen(Color.Black, 0), 0, 0, image.Width - 1, image.Height - 1); //输出到浏览器 System.IO.MemoryStream ms = new System.IO.MemoryStream(); image.Save(ms, System.Drawing.Imaging.ImageFormat.Gif); HttpContext.Current.Response.ClearContent(); //Response.ClearContent(); HttpContext.Current.Response.ContentType = "image/gif"; HttpContext.Current.Response.BinaryWrite(ms.ToArray()); g.Dispose(); image.Dispose(); } #endregion
  • 2021-02-20 01:35:01
最新发布的资讯信息
【简历/资料|内地女明星】 殷茹基本资料( YR个人简历介绍)(2020-12-06 15:19)
【简历/资料|内地女明星】 曹菁基本资料( CJ个人简历介绍)(2020-12-06 15:18)
【简历/资料|内地女明星】 王安妮基本资料( WAN个人简历介绍)(2020-12-06 15:18)
【简历/资料|内地女明星】 白琼基本资料( BQ个人简历介绍)(2020-12-06 15:17)
【简历/资料|内地女明星】 王世霞基本资料( WSX个人简历介绍)(2020-12-06 15:17)
【简历/资料|内地女明星】 宋煜基本资料( SY个人简历介绍)(2020-12-06 15:16)
【简历/资料|内地女明星】 钱增基本资料( QZ个人简历介绍)(2020-12-06 15:16)
【简历/资料|内地女明星】 胡晓黎基本资料( HXL个人简历介绍)(2020-12-06 15:15)
【简历/资料|内地女明星】 李佳慧基本资料( LJH个人简历介绍)(2020-12-06 15:15)
【简历/资料|内地女明星】 张洛嘉基本资料( ZLJ个人简历介绍)(2020-12-06 15:14)
联系客服
网站客服 联系客服
手机版

扫一扫进手机版
返回顶部