验证码实例

我做的这个验证码是在Google扭曲验证码的基础上做的修改
包含下列文件:
1.App_Code/VerifyCode.cs

None.gifusing System;
None.gif
using System.Data;
None.gif
using System.Configuration;
None.gif
using System.Web;
None.gif
using System.Web.Security;
None.gif
using System.Web.UI;
None.gif
using System.Web.UI.WebControls;
None.gif
using System.Web.UI.WebControls.WebParts;
None.gif
using System.Web.UI.HtmlControls;
None.gif
using System.Drawing;
None.gif 
ExpandedBlockStart.gifContractedBlock.gif
/**////<summary>
InBlock.gif
/// VerifyCode 的摘要说明
ExpandedBlockEnd.gif
///</summary>

None.gifpublic class VerifyCode
ExpandedBlockStart.gifContractedBlock.gif
dot.gif{
ContractedSubBlock.gifExpandedSubBlockStart.gif    
验证码长度(默认6个验证码的长度)#region 验证码长度(默认6个验证码的长度)
InBlock.gif    
int length = 6;
InBlock.gif    
public int Length
ExpandedSubBlockStart.gifContractedSubBlock.gif    
dot.gif{
ExpandedSubBlockStart.gifContractedSubBlock.gif        
get dot.gifreturn length; }
ExpandedSubBlockStart.gifContractedSubBlock.gif        
set dot.gif{ length = value; }
ExpandedSubBlockEnd.gif    }

ExpandedSubBlockEnd.gif    
#endregion

ContractedSubBlock.gifExpandedSubBlockStart.gif    
验证码字体大小默认40像素#region 验证码字体大小默认40像素
InBlock.gif    
int fontSize = 30;
InBlock.gif    
public int FontSize
ExpandedSubBlockStart.gifContractedSubBlock.gif    
dot.gif{
ExpandedSubBlockStart.gifContractedSubBlock.gif        
get dot.gifreturn fontSize; }
ExpandedSubBlockStart.gifContractedSubBlock.gif        
set dot.gif{ fontSize = value; }
ExpandedSubBlockEnd.gif    }

ExpandedSubBlockEnd.gif    
#endregion

ContractedSubBlock.gifExpandedSubBlockStart.gif    
边框补#region 边框补
InBlock.gif    
int padding = 2;
InBlock.gif    
public int Padding
ExpandedSubBlockStart.gifContractedSubBlock.gif    
dot.gif{
ExpandedSubBlockStart.gifContractedSubBlock.gif        
get dot.gifreturn padding; }
ExpandedSubBlockStart.gifContractedSubBlock.gif        
set dot.gif{ padding = value; }
ExpandedSubBlockEnd.gif    }

ExpandedSubBlockEnd.gif    
#endregion

ContractedSubBlock.gifExpandedSubBlockStart.gif    
是否输出燥点(默认不输出)#region 是否输出燥点(默认不输出)
InBlock.gif    
bool chaos = true;
InBlock.gif    
public bool Chaos
ExpandedSubBlockStart.gifContractedSubBlock.gif    
dot.gif{
ExpandedSubBlockStart.gifContractedSubBlock.gif        
get dot.gifreturn chaos; }
ExpandedSubBlockStart.gifContractedSubBlock.gif        
set dot.gif{ chaos = value; }
ExpandedSubBlockEnd.gif    }

ExpandedSubBlockEnd.gif    
#endregion

ContractedSubBlock.gifExpandedSubBlockStart.gif    
输出燥点的颜色(默认灰色)#region 输出燥点的颜色(默认灰色)
InBlock.gif    Color chaosColor 
= Color.LightGray;
InBlock.gif    
public Color ChaosColor
ExpandedSubBlockStart.gifContractedSubBlock.gif    
dot.gif{
ExpandedSubBlockStart.gifContractedSubBlock.gif        
get dot.gifreturn chaosColor; }
ExpandedSubBlockStart.gifContractedSubBlock.gif        
set dot.gif{ chaosColor = value; }
ExpandedSubBlockEnd.gif    }

ExpandedSubBlockEnd.gif    
#endregion

ContractedSubBlock.gifExpandedSubBlockStart.gif    
自定义背景色(默认白色)#region 自定义背景色(默认白色)
InBlock.gif    Color backgroundColor 
= Color.White;
InBlock.gif    
public Color BackgroundColor
ExpandedSubBlockStart.gifContractedSubBlock.gif    
dot.gif{
ExpandedSubBlockStart.gifContractedSubBlock.gif        
get dot.gifreturn backgroundColor; }
ExpandedSubBlockStart.gifContractedSubBlock.gif        
set dot.gif{ backgroundColor = value; }
ExpandedSubBlockEnd.gif    }

ExpandedSubBlockEnd.gif    
#endregion

ContractedSubBlock.gifExpandedSubBlockStart.gif    
自定义随机颜色数组#region 自定义随机颜色数组
ExpandedSubBlockStart.gifContractedSubBlock.gif    Color[] colors 
= dot.gif{ Color.Black, Color.Red, Color.DarkBlue, Color.Green, Color.Orange, Color.Brown, Color.DarkCyan, Color.Purple };
InBlock.gif    
public Color[] Colors
ExpandedSubBlockStart.gifContractedSubBlock.gif    
dot.gif{
ExpandedSubBlockStart.gifContractedSubBlock.gif        
get dot.gifreturn colors; }
ExpandedSubBlockStart.gifContractedSubBlock.gif        
set dot.gif{ colors = value; }
ExpandedSubBlockEnd.gif    }

ExpandedSubBlockEnd.gif    
#endregion

ContractedSubBlock.gifExpandedSubBlockStart.gif    
自定义字体数组#region 自定义字体数组
ExpandedSubBlockStart.gifContractedSubBlock.gif    
string[] fonts = dot.gif"Gautami" };//{"宋体"};//设置字体
InBlock.gif
    public string[] Fonts
ExpandedSubBlockStart.gifContractedSubBlock.gif    
dot.gif{
ExpandedSubBlockStart.gifContractedSubBlock.gif        
get dot.gifreturn fonts; }
ExpandedSubBlockStart.gifContractedSubBlock.gif        
set dot.gif{ fonts = value; }
ExpandedSubBlockEnd.gif    }

ExpandedSubBlockEnd.gif    
#endregion

ContractedSubBlock.gifExpandedSubBlockStart.gif    
自定义随机码字符串序列(使用逗号分隔)#region 自定义随机码字符串序列(使用逗号分隔)
InBlock.gif    
string codeSerial = "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
InBlock.gif
    public string CodeSerial
ExpandedSubBlockStart.gifContractedSubBlock.gif    
dot.gif{
ExpandedSubBlockStart.gifContractedSubBlock.gif        
get dot.gifreturn codeSerial; }
ExpandedSubBlockStart.gifContractedSubBlock.gif        
set dot.gif{ codeSerial = value; }
ExpandedSubBlockEnd.gif    }

ExpandedSubBlockEnd.gif    
#endregion

ContractedSubBlock.gifExpandedSubBlockStart.gif    
产生波形滤镜效果#region 产生波形滤镜效果
InBlock.gif    
private const double PI = 0//3.1415926535897932384626433832795;
InBlock.gif
    private const double PI2 = 0;</spa>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值