[求助] 请各位达人修改此非常强悍的asp.net验证码

hanyuice 2008-07-30 04:07:12






验证码下载地址:http://www.lanray.com/tools/CaptchaControlDemo.zip

-----------------------------------
需求如下:

此为VB.NET编写的一个验证码控件,我需要将此控件改成一个C#版的aspx类型的验证码文件,并且可以用session判断验证码

本人QQ:1483683

愿各位达人不吝赐教,在线等各位的佳音!

200分献上!(发贴只能设成100,搞定后我再给100)
...全文
359 29 打赏 收藏 转发到动态 举报
写回复
用AI写文章
29 条回复
切换为时间正序
请发表友善的回复…
发表回复
hanyuice 2009-03-24
  • 打赏
  • 举报
回复
再来顶上去
hanyuice 2008-08-07
  • 打赏
  • 举报
回复
来高手啊,帮忙整一整么,实在需要呢,CSDN上的高手何在,要帮忙啊
aaajedll 2008-08-03
  • 打赏
  • 举报
回复
[Quote=引用 22 楼 xiaoxue1129 的回复:]
还可以 ,学习一下了
[/Quote]
xiaoxue1129 2008-08-03
  • 打赏
  • 举报
回复
还可以 ,学习一下了
shadowjl 2008-08-03
  • 打赏
  • 举报
回复
学习
firefoxxx 2008-08-03
  • 打赏
  • 举报
回复
额 保留下 貌似有用
YiCaoYiMu08 2008-08-03
  • 打赏
  • 举报
回复
YiCaoYiMu08 2008-08-03
  • 打赏
  • 举报
回复


这样的好呗?
atlasroben 2008-08-03
  • 打赏
  • 举报
回复
[Quote=引用 15 楼 suyiming 的回复:]
仿


C# codenamespace Kissogram.Common.Security
{
using System;
using System.IO;
using System.Web;
using System.Drawing;

//GIF验证码类
public class Validate
{
//设置最少4位验证码
private byte TrueValidateCodeCount = 4;
public byte ValidateCodeCount
{
get
{
retur…
[/Quote]

这个貌似调用了其他的dll,有用c#生成gif动画效果的代码吗?
zld_baggio 2008-08-03
  • 打赏
  • 举报
回复
[Quote=引用 23 楼 aaajedll 的回复:]
引用 22 楼 xiaoxue1129 的回复:
还可以 ,学习一下了
[/Quote]
紫气东来_999 2008-08-02
  • 打赏
  • 举报
回复
[Quote=引用 15 楼 suyiming 的回复:]
仿


C# codenamespace Kissogram.Common.Security
{
using System;
using System.IO;
using System.Web;
using System.Drawing;

//GIF验证码类
public class Validate
{
//设置最少4位验证码
private byte TrueValidateCodeCount = 4;
public byte ValidateCodeCount
{
get
{
retur…
[/Quote]


这个测试版?
hanyuice 2008-08-02
  • 打赏
  • 举报
回复
不能沉底啊,顶起来先~
hanyuice 2008-08-02
  • 打赏
  • 举报
回复
suyiming兄发的好像是他搜信的一个,但不是我要求的那种,不知道还有没有达人帮忙整
哪怕搞定我再给100分,300分送上,还望兄弟们帮忙了~
hanyuice 2008-08-01
  • 打赏
  • 举报
回复
楼上的仁兄能否发一个使用实例,我调试了一下,报错!
还望指教,最好能帮我把我发的那个验证码也帮我弄一下,拜托了
suyiming 2008-07-31
  • 打赏
  • 举报
回复
仿

namespace Kissogram.Common.Security
{
using System;
using System.IO;
using System.Web;
using System.Drawing;

//GIF验证码类
public class Validate
{
//设置最少4位验证码
private byte TrueValidateCodeCount = 4;
public byte ValidateCodeCount
{
get
{
return TrueValidateCodeCount;
}
set
{
//验证码至少为3位
if (value > 4)
TrueValidateCodeCount = value;
}
}
protected string ValidateCode = "";
//是否消除锯齿
public bool FontTextRenderingHint = false;
//验证码字体
public string ValidateCodeFont = "Arial";
//验证码型号(像素)
public float ValidateCodeSize = 13;
public int ImageHeight = 23;
//定义验证码中所有的字符
public string AllChar = "1,2,3,4,5,6,7,8,9,0,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,W,X,Y,Z";

//获得随机四位数
private void CreateValidate()
{
ValidateCode = "";
//将验证码中所有的字符保存在一个字符串数组中
string[] CharArray = AllChar.Split(',');
int Temp = -1;
//生成一个随机对象
Random RandCode = new Random();
//根据验证码的位数循环
for (int i = 0; i < ValidateCodeCount; i++)
{
//主要是防止生成相同的验证码
if (Temp != -1)
{
//加入时间的刻度
RandCode = new Random(i * Temp * ((int)DateTime.Now.Ticks));
}
int t = RandCode.Next(35);
if (Temp == t)
{
//相等的话重新生成
CreateValidate();
}
Temp = t;
ValidateCode += CharArray[Temp];
}
//错误检测,去除超过指定位数的验证码
if (ValidateCode.Length > TrueValidateCodeCount)
ValidateCode = ValidateCode.Remove(TrueValidateCodeCount);
}
//生成一帧的BMP图象
private void CreateImageBmp(out Bitmap ImageFrame)
{
//获得验证码字符
char[] CodeCharArray = ValidateCode.ToCharArray(0, ValidateCodeCount);
//图像的宽度-与验证码的长度成一定比例
int ImageWidth = (int)(TrueValidateCodeCount * ValidateCodeSize * 1.3 + 4);
//创建一个长20,宽iwidth的图像对象
ImageFrame = new Bitmap(ImageWidth, ImageHeight);
//创建一个新绘图对象
Graphics ImageGraphics = Graphics.FromImage(ImageFrame);
//清除背景色,并填充背景色
//Note:Color.Transparent为透明
ImageGraphics.Clear(Color.White);
//绘图用的字体和字号
Font CodeFont = new Font(ValidateCodeFont, ValidateCodeSize, FontStyle.Bold);
//绘图用的刷子大小
Brush ImageBrush = new SolidBrush(Color.Red);
//字体高度计算
int FontHeight = (int)Math.Max(ImageHeight - ValidateCodeSize - 3, 2);
//创建随机对象
Random rand = new Random();
//开始随机安排字符的位置,并画到图像里
for (int i = 0; i < TrueValidateCodeCount; i++)
{
//生成随机点,决定字符串的开始输出范围
int[] FontCoordinate = new int[2];
FontCoordinate[0] = (int)(i * ValidateCodeSize + rand.Next(1)) + 3;
FontCoordinate[1] = rand.Next(FontHeight);
Point FontDrawPoint = new Point(FontCoordinate[0], FontCoordinate[1]);
//消除锯齿操作
if (FontTextRenderingHint)
ImageGraphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.SingleBitPerPixel;
else
ImageGraphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;
//格式化刷子属性-用指定的刷子、颜色等在指定的范围内画图
ImageGraphics.DrawString(CodeCharArray[i].ToString(), CodeFont, ImageBrush, FontDrawPoint);
}
ImageGraphics.Dispose();
}
//处理生成的BMP
private void DisposeImageBmp(ref Bitmap ImageFrame)
{
//创建绘图对象
Graphics ImageGraphics = Graphics.FromImage(ImageFrame);
//创建铅笔对象
Pen ImagePen = new Pen(Color.Red, 1);
//创建随机对象
Random rand = new Random();
//创建随机点
Point[] RandPoint = new Point[2];
//随机画线
for (int i = 0; i < 15; i++)
{
RandPoint[0] = new Point(rand.Next(ImageFrame.Width), rand.Next(ImageFrame.Height));
RandPoint[1] = new Point(rand.Next(ImageFrame.Width), rand.Next(ImageFrame.Height));
ImageGraphics.DrawLine(ImagePen, RandPoint[0], RandPoint[1]);
}
ImageGraphics.Dispose();
}
//创建GIF动画
private void CreateImageGif()
{
Bitmap ImageFrame;
Kissogram.Drawing.Gif.AnimatedGifEncoder GifPic = new Kissogram.Drawing.Gif.AnimatedGifEncoder();
MemoryStream BmpMemory = new MemoryStream();
GifPic.Start();
//确保视觉残留
GifPic.SetDelay(5);
//-1:no repeat,0:always repeat
GifPic.SetRepeat(0);
for (int i = 0; i < 20; i++)
{
//创建一帧的图像
CreateImageBmp(out ImageFrame);
//生成随机线条
DisposeImageBmp(ref ImageFrame);
//输出绘图,将图像保存到指定的流
ImageFrame.Save(BmpMemory, System.Drawing.Imaging.ImageFormat.Png);
GifPic.AddFrame(Image.FromStream(BmpMemory));
BmpMemory = new MemoryStream();
}
GifPic.OutPut(ref BmpMemory);
HttpContext.Current.Response.ClearContent();
//配置输出类型
HttpContext.Current.Response.ContentType = "image/Gif";
//输出内容
HttpContext.Current.Response.BinaryWrite(BmpMemory.ToArray());
BmpMemory.Close();
BmpMemory.Dispose();
}
//输出验证码
public void OutPutValidate(string ValidateCodeSession)
{
CreateValidate();
CreateImageGif();
//把生成的验证码输入到SESSION
HttpContext.Current.Session[ValidateCodeSession] = ValidateCode;
}
}
}
hanyuice 2008-07-31
  • 打赏
  • 举报
回复
直接追加了一百分,请各位务必帮忙解决此问题,本人再次承诺,搞定此问题者,我可以再加一百分,共三百分奉上
hanyuice 2008-07-31
  • 打赏
  • 举报
回复
各位请不要误会,验证码文件我也有好一些,但我对此验证码情有独钟,前些时候在一国外的网站上下得此验证码,是控件型的,C#也可以调用,但是请各位调试一下就知道了,这个控件是连验证一起带上的,所以我才需要达人们来修改此验证码,达到我的要求!
希望各位高手帮帮忙了啊~
  • 打赏
  • 举报
回复
我记得CSDN博客里有介绍。
但是我看到一个就是天涯注册码,将大写中文数字写成数字的验证码。
其实验证码好像有点智能化的效果,不知道我说的对不对。呵呵。
winner2050 2008-07-30
  • 打赏
  • 举报
回复
那些验证码虽然很乱,但是很容易破解.

因为粗细太明显了.

而且验证码保护可以用人类的逻辑对付机器的死板.

比如隐藏验证码,当输入用户名密码以后才显示验证码.

现在很多网站这么作了.
soldierluo 2008-07-30
  • 打赏
  • 举报
回复
我这有一个你要不要
加载更多回复(9)

62,041

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

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