求一验证码识别

zhlym 2014-09-16 05:59:04
那位朋友如下验证码识别c#代码, 能不能共享出来用一用,非常感谢
http://www.queensalon.com/CON55F.gif
图片上传不了,只能贴个网址
...全文
267 12 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
失落的神庙 2014-09-18
  • 打赏
  • 举报
回复
引用 11 楼 zhlym 的回复:
[quote=引用 10 楼 liucqa 的回复:] 这有什么难的,去掉干扰线,做字库,识别即可,最简单的活了
嗯,会的都这么说的,兄弟有例子的发出来用用了[/quote] 多去看看教程吧。 百度google 次世代 验证码识别教程
zhlym 2014-09-17
  • 打赏
  • 举报
回复
问题还等待解决,在会的朋友路过
zhlym 2014-09-17
  • 打赏
  • 举报
回复
引用 7 楼 vbload 的回复:
字符较简单,根据例子自己研究下,识别不太复杂的。
唉没有这方面的知识,还未能解决,等待会的朋友路过给个源码例子
zhlym 2014-09-17
  • 打赏
  • 举报
回复
引用 10 楼 liucqa 的回复:
这有什么难的,去掉干扰线,做字库,识别即可,最简单的活了
嗯,会的都这么说的,兄弟有例子的发出来用用了
泡泡龙 2014-09-17
  • 打赏
  • 举报
回复
这有什么难的,去掉干扰线,做字库,识别即可,最简单的活了
网络菜鸟00 2014-09-17
  • 打赏
  • 举报
回复
字符较简单,根据例子自己研究下,识别不太复杂的。
zhlym 2014-09-17
  • 打赏
  • 举报
回复
顶一顶等待会的朋友
蝶恋花雨 2014-09-16
  • 打赏
  • 举报
回复
引用 4 楼 zhlym 的回复:
TO kongwei521 兄弟,我要的是识别,你的是生成,搞反了..... 麻烦有的发一个识别的例子,谢谢谢谢
搞反了,不好意思 http://blog.sina.com.cn/s/blog_444e54ff01011mfp.html  http://blog.csdn.net/stevenkylelee/article/details/8270069 http://www.cnblogs.com/c-source/archive/2012/04/17/2565136.html
zhlym 2014-09-16
  • 打赏
  • 举报
回复
引用 3 楼 kongwei521 的回复:
TO kongwei521 兄弟,我要的是识别,你的是生成,搞反了..... 麻烦有的发一个识别的例子,谢谢谢谢
蝶恋花雨 2014-09-16
  • 打赏
  • 举报
回复
蝶恋花雨 2014-09-16
  • 打赏
  • 举报
回复
使用方法:
<input type="text" runat="server"  ID="yanzheng"     maxlength="5" style="height:22px; width:70px; border:solid 1px #cadcb2; font-size:12px; color:#81b432;" /> </div>
               <div style="float:right; padding-top:2px;"><img id="yan" alt="刷新验证码"  style=" cursor:pointer" onclick="javascript:DianJi();" src="../UserControl/ValidateCode.aspx"  /> </div>
JS刷新i:
function DianJi()//刷新验证码
	{ document.getElementById("yan").src = "../UserControl/ValidateCode.aspx" + "?" + Math.random(); }
蝶恋花雨 2014-09-16
  • 打赏
  • 举报
回复
参考效果和你的一样
	 public partial class ValidateCode : System.Web.UI.Page
	 {
		  protected void Page_Load(object sender, EventArgs e)
		  {
			   string tmp = RndNum(5).ToUpper();
			   this.Session["ImageV"] = tmp;
			   HttpCookie a = new HttpCookie("ImageV", tmp);
			   Response.Cookies.Add(a);
			   this.CreateCheckCodeImage(tmp);
		  }
		  #region//创建验证码
		  protected void ValidateCodeCreate(string VNum)
		  {
			   Bitmap Img = null;
			   Graphics g = null;
			   MemoryStream ms = null;

			   int gheight = VNum.Length * 10;
			   Img = new Bitmap(gheight, 25);
			   g = Graphics.FromImage(Img);
			   //背景颜色 
			   g.Clear(Color.White);
			   //文字字体 
			   Font f = new Font("Arial Black", 10);
			   //文字颜色 
			   SolidBrush s = new SolidBrush(Color.Black);
			   g.DrawString(VNum, f, s, 3, 3);
			   ms = new MemoryStream();
			   Img.Save(ms, ImageFormat.Jpeg);
			   Response.ClearContent();
			   Response.ContentType = "image/Jpeg";
			   Response.BinaryWrite(ms.ToArray());

			   g.Dispose();
			   Img.Dispose();
			   Response.End();
		  }
		  #endregion
		  #region//生验证码随即数字+字母组合
		  private string RndNum(int VcodeNum)
		  {
			   string Vchar = "a,b,c,d,e,0,1,2,3,4,5,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,0,1,2,3,4,5,6,7,8,9,w,x,y,z,a,b,c,d,e,f,g,h,i,j,k,l,m,1,2,3,4,5,6,7,8,9,n,o,p,q,r,s,t,u,v,w,x,y,z";
			   string[] VcArray = Vchar.Split(new Char[] { ',' });
			   string VNum = "";
			   int temp = -1;

			   Random rand = new Random();

			   for (int i = 1; i < VcodeNum + 1; i++)
			   {
					if (temp != -1)
					{
						 rand = new Random(i * temp * unchecked((int)DateTime.Now.Ticks));
					}

					int t = rand.Next(35);
					if (temp != -1 && temp == t)
					{
						 return RndNum(VcodeNum);
					}
					temp = t;
					VNum += VcArray[t];
			   }
			   return VNum;
		  }
		  #endregion
		  #region //创建验证码背景图片
		  private void CreateCheckCodeImage(string checkCode)
		  {
			   if (checkCode == null || checkCode.Trim() == String.Empty)
					return;

			   System.Drawing.Bitmap image = new System.Drawing.Bitmap((int)Math.Ceiling((checkCode.Length * 13.0)), 21);
			   Graphics g = Graphics.FromImage(image);

			   try
			   {
					//生成随机生成器

					Random random = new Random();

					//清空图片背景色

					g.Clear(Color.White);

					//画图片的背景噪音线

					for (int i = 0; i < 25; i++)
					{
						 int x1 = random.Next(image.Width);
						 int x2 = random.Next(image.Width);
						 int y1 = random.Next(image.Height);
						 int y2 = random.Next(image.Height);

						 g.DrawLine(new Pen(Color.Silver), x1, y1, x2, y2);
					}

					Font font = new System.Drawing.Font("Arial", 12, (System.Drawing.FontStyle.Bold | System.Drawing.FontStyle.Italic));
					System.Drawing.Drawing2D.LinearGradientBrush brush = new System.Drawing.Drawing2D.LinearGradientBrush(new Rectangle(0, 0, image.Width, image.Height), Color.Blue, Color.DarkRed, 1.2f, true);
					g.DrawString(checkCode, font, brush, 2, 1);

					//画图片的前景噪音点

					for (int i = 0; i < 100; i++)
					{
						 int x = random.Next(image.Width);
						 int y = random.Next(image.Height);

						 image.SetPixel(x, y, Color.FromArgb(random.Next()));
					}

					//画图片的边框线

					g.DrawRectangle(new Pen(Color.Silver), 0, 0, image.Width - 1, image.Height - 1);

					System.IO.MemoryStream ms = new System.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();
			   }
		  }
		  #endregion
	 }
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ValidateCode.aspx.cs" Inherits="HaiPaiHuanYi.UserControl.ValidateCode" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    
    </div>
    </form>
</body>
</html>

111,093

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • AIGC Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧