ASP 验证码的程序及原理

验证码ASP源代码 在ASP页面中生成图片验证码,需要用到System.Drawing命名空间下的很多类,首先我们需要新建一个CreateImage.aspx页面,在后台代码中定义用于生成验证码图片的方法,如下:{{//产生4位验证码//用于验证}////// 产生验证码/////////{i++){//一个大于或等于minValue 且小于maxValue 的32 位带符号整数,即:返回的值范围包括minValue 但不包括maxValue。如果。 阅读详情
##### 版权所有 转载请保留 谢谢合作 
##### 部分程序取自网络 
##### 作者:扬子 
##### Email: yangzinet@hotmail.com 
##### QQ: 21112856
##### WebSite: www.tingfo.net 

 

一共4个页面:form.asp; chk.asp; num.asp; count.asp
得到一个随即数字。加密!
解密后成成XBM图片
利用session 判断

form.asp
<%
'### To encrypt/decrypt include this code in your page 
'### strMyEncryptedString = EncryptString(strString)
'### strMyDecryptedString = DeCryptString(strMyEncryptedString)
'### You are free to use this code as long as credits remain in place
'### also if you improve this code let me know.

Private Function EncryptString(strString)
'####################################################################
'### Crypt Function (C) 2001 by Slavic Kozyuk grindkore@yahoo.com ###
'### Arguments: strString <--- String you wish to encrypt ###
'### Output: Encrypted HEX string ###
'####################################################################

    Dim CharHexSet, intStringLen, strTemp, strRAW, i, intKey, intOffSet
    Randomize Timer

    intKey = Round((RND * 1000000) + 1000000) '##### Key Bitsize
    intOffSet = Round((RND * 1000000) + 1000000) '##### KeyOffSet Bitsize

    If IsNull(strString) = False Then
        strRAW = strString
        intStringLen = Len(strRAW)

        For i = 0 to intStringLen - 1
            strTemp = Left(strRAW, 1)
            strRAW = Right(strRAW, Len(strRAW) - 1)
            CharHexSet = CharHexSet & Hex(Asc(strTemp) * intKey)& Hex(intKey)
        Next

        EncryptString = CharHexSet & "|" & Hex(intOffSet + intKey) & "|" & Hex(intOffSet)
    Else
        EncryptString = ""
    End If
End Function


Private Function DeCryptString(strCryptString)
'####################################################################
'### Crypt Function (C) 2001 by Slavic Kozyuk grindkore@yahoo.com ###
'### Arguments: Encrypted HEX stringt ###
'### Output: Decrypted ASCII string ###
'####################################################################
'### Note this function uses HexConv() and get_hxno() functions ###
'### so make sure they are not removed ###
'####################################################################

    Dim strRAW, arHexCharSet, i, intKey, intOffSet, strRawKey, strHexCrypData

    strRawKey = Right(strCryptString, Len(strCryptString) - InStr(strCryptString, "|"))
    intOffSet = Right(strRawKey, Len(strRawKey) - InStr(strRawKey,"|"))
    intKey = HexConv(Left(strRawKey, InStr(strRawKey, "|") - 1)) - HexConv(intOffSet)
    strHexCrypData = Left(strCryptString, Len(strCryptString) - (Len(strRawKey) + 1))

    arHexCharSet = Split(strHexCrypData, Hex(intKey))

    For i=0 to UBound(arHexCharSet)
        strRAW = strRAW & Chr(HexConv(arHexCharSet(i))/intKey)
    Next

    DeCryptString = strRAW
End Function

Private Function HexConv(hexVar)
    Dim hxx, hxx_var, multiply 
    IF hexVar <> "" THEN
        hexVar = UCASE(hexVar)
        hexVar = StrReverse(hexVar)
        DIM hx()
        REDIM hx(LEN(hexVar))
        hxx = 0
        hxx_var = 0
        FOR hxx = 1 TO LEN(hexVar)
            IF multiply = "" THEN multiply = 1
            hx(hxx) = mid(hexVar,hxx,1)
            hxx_var = (get_hxno(hx(hxx)) * multiply) + hxx_var
            multiply = (multiply * 16)
        NEXT
        hexVar = hxx_var
        HexConv = hexVar
    END IF
End Function

Private Function get_hxno(ghx)
    If ghx = "A" Then
        ghx = 10
    ElseIf ghx = "B" Then
        ghx = 11
    ElseIf ghx = "C" Then
        ghx = 12
    ElseIf ghx = "D" Then
        ghx = 13
    ElseIf ghx = "E" Then
        ghx = 14
    ElseIf ghx = "F" Then
        ghx = 15
    End If
    get_hxno = ghx
End Function

%>

<%
randomize
num = int(7999*rnd+2000) '计数器的值
num2 = EncryptString(num)
session("pwdt")=num
%>
<form action="chk.asp" method=post>
请输入验证码: <input type="text" name="pwds">
<img src="count.asp?sksid=<%=num2%>"> <input type=submit value=提交>
</form>

chk.asp
<%
if trim(request.form("pwds"))<>trim(session("pwdt")) then
%>
输入错误: 应该为:<%=session("pwdt")%>,可你输入的是:<%=request.form("pwds")%>
<%
else
%>
输入正确
<%end if%>

count.asp
<!--#include file="num.asp"-->
<%
'### To encrypt/decrypt include this code in your page 
'### strMyEncryptedString = EncryptString(strString)
'### strMyDecryptedString = DeCryptString(strMyEncryptedString)
'### You are free to use this code as long as credits remain in place
'### also if you improve this code let me know.

Private Function EncryptString(strString)
'####################################################################
'### Crypt Function (C) 2001 by Slavic Kozyuk grindkore@yahoo.com ###
'### Arguments: strString <--- String you wish to encrypt ###
'### Output: Encrypted HEX string ###
'####################################################################

    Dim CharHexSet, intStringLen, strTemp, strRAW, i, intKey, intOffSet
    Randomize Timer

    intKey = Round((RND * 1000000) + 1000000) '##### Key Bitsize
    intOffSet = Round((RND * 1000000) + 1000000) '##### KeyOffSet Bitsize

    If IsNull(strString) = False Then
        strRAW = strString
        intStringLen = Len(strRAW)

        For i = 0 to intStringLen - 1
            strTemp = Left(strRAW, 1)
            strRAW = Right(strRAW, Len(strRAW) - 1)
            CharHexSet = CharHexSet & Hex(Asc(strTemp) * intKey)& Hex(intKey)
        Next

        EncryptString = CharHexSet & "|" & Hex(intOffSet + intKey) & "|" & Hex(intOffSet)
    Else
        EncryptString = ""
    End If
End Function

Private Function DeCryptString(strCryptString)
'####################################################################
'### Crypt Function (C) 2001 by Slavic Kozyuk grindkore@yahoo.com ###
'### Arguments: Encrypted HEX stringt ###
'### Output: Decrypted ASCII string ###
'####################################################################
'### Note this function uses HexConv() and get_hxno() functions ###
'### so make sure they are not removed ###
'####################################################################

    Dim strRAW, arHexCharSet, i, intKey, intOffSet, strRawKey, strHexCrypData

    strRawKey = Right(strCryptString, Len(strCryptString) - InStr(strCryptString, "|"))
    intOffSet = Right(strRawKey, Len(strRawKey) - InStr(strRawKey,"|"))
    intKey = HexConv(Left(strRawKey, InStr(strRawKey, "|") - 1)) - HexConv(intOffSet)
    strHexCrypData = Left(strCryptString, Len(strCryptString) - (Len(strRawKey) + 1))

    arHexCharSet = Split(strHexCrypData, Hex(intKey))

    For i=0 to UBound(arHexCharSet)
        strRAW = strRAW & Chr(HexConv(arHexCharSet(i))/intKey)
    Next

    DeCryptString = strRAW
End Function

Private Function HexConv(hexVar)
    Dim hxx, hxx_var, multiply 
    IF hexVar <> "" THEN
        hexVar = UCASE(hexVar)
        hexVar = StrReverse(hexVar)
        DIM hx()
        REDIM hx(LEN(hexVar))
        hxx = 0
        hxx_var = 0
        FOR hxx = 1 TO LEN(hexVar)
            IF multiply = "" THEN multiply = 1
            hx(hxx) = mid(hexVar,hxx,1)
            hxx_var = (get_hxno(hx(hxx)) * multiply) + hxx_var
            multiply = (multiply * 16)
        NEXT
        hexVar = hxx_var
        HexConv = hexVar
    END IF
End Function

Private Function get_hxno(ghx)
    If ghx = "A" Then
        ghx = 10
    ElseIf ghx = "B" Then
        ghx = 11
    ElseIf ghx = "C" Then
        ghx = 12
    ElseIf ghx = "D" Then
        ghx = 13
    ElseIf ghx = "E" Then
        ghx = 14
    ElseIf ghx = "F" Then
        ghx = 15
    End If
    get_hxno = ghx
End Function

%>


<%
Dim Image
Dim Width, Height
Dim num
Dim digtal
Dim Length
Dim sort
Length = 4 '自定计数器长度

Redim sort( Length )

num=cint(DeCryptString(request.querystring("sksid")))
digital = ""
For I = 1 To Length -Len( num ) '补0
    digital = digital & "0"
Next
For I = 1 To Len( num )
    digital = digital & Mid( num, I, 1 )
Next
For I = 1 To Len( digital )
    sort(I) = Mid( digital, I, 1 )
Next
Width = 8 * Len( digital ) '图像的宽度
Height = 10 '图像的高度,在本例中为固定值

Response.ContentType="image/x-xbitmap"

hc=chr(13) & chr(10) 

Image = "#define counter_width " & Width & hc
Image = Image & "#define counter_height " & Height & hc
Image = Image & "static unsigned char counter_bits[]={" & hc

For I = 1 To Height
    For J = 1 To Length
        Image = Image & a(sort(J),I) & ","
    Next
Next

Image = Left( Image, Len( Image ) - 1 ) '去掉最后一个逗号
Image = Image & "};" & hc
%>
<%
Response.Write Image
%>

num.asp
<%
Dim a(10,10)

a(0,1) = "0x3c" '数字0
a(0,2) = "0x66"
a(0,3) = "0xc3"
a(0,4) = "0xc3"
a(0,5) = "0xc3"
a(0,6) = "0xc3"
a(0,7) = "0xc3"
a(0,8) = "0xc3"
a(0,9) = "0x66"
a(0,10)= "0x3c"

a(1,1) = "0x18" '数字1
a(1,2) = "0x1c"
a(1,3) = "0x18"
a(1,4) = "0x18"
a(1,5) = "0x18"
a(1,6) = "0x18"
a(1,7) = "0x18"
a(1,8) = "0x18"
a(1,9) = "0x18"
a(0,10)= "0x7e"


a(2,1) = "0x3c" '数字2
a(2,2) = "0x66"
a(2,3) = "0x60"
a(2,4) = "0x60"
a(2,5) = "0x30"
a(2,6) = "0x18"
a(2,7) = "0x0c"
a(2,8) = "0x06"
a(2,9) = "0x06"
a(2,10)= "0x7e"

a(3,1) = "0x3c" '数字3
a(3,2) = "0x66"
a(3,3) = "0xc0"
a(3,4) = "0x60"
a(3,5) = "0x1c"
a(3,6) = "0x60"
a(3,7) = "0xc0"
a(3,8) = "0xc0"
a(3,9) = "0x66"
a(3,10)= "0x38"

a(4,1) = "0x38" '数字4
a(4,2) = "0x3c"
a(4,3) = "0x36"
a(4,4) = "0x33"
a(4,5) = "0x33"
a(4,6) = "0x33"
a(4,7) = "0xff"
a(4,8) = "0x30"
a(4,9) = "0x30"
a(4,10)= "0xfe"

a(5,1) = "0xfe" '数字5
a(5,2) = "0xfe"
a(5,3) = "0x06"
a(5,4) = "0x06"
a(5,5) = "0x3e"
a(5,6) = "0x60"
a(5,7) = "0xc0"
a(5,8) = "0xc3"
a(5,9) = "0x66"
a(5,10)= "0x3c"

a(6,1) = "0x60" '数字6
a(6,2) = "0x30"
a(6,3) = "0x18"
a(6,4) = "0x0c"
a(6,5) = "0x3e"
a(6,6) = "0x63"
a(6,7) = "0xc3"
a(6,8) = "0xc3"
a(6,9) = "0x66"
a(6,10) ="0x3c"

a(7,1) = "0xff" '数字7
a(7,2) = "0xc0"
a(7,3) = "0x60"
a(7,4) = "0x30"
a(7,5) = "0x18"
a(7,6) = "0x18"
a(7,7) = "0x18"
a(7,8) = "0x18"
a(7,9) = "0x18"
a(7,10)= "0x18"

a(8,1) = "0x3c" '数字8
a(8,2) = "0x66"
a(8,3) = "0xc3"
a(8,4) = "0x66"
a(8,5) = "0x3c"
a(8,6) = "0x66"
a(8,7) = "0xc3"
a(8,8) = "0xc3"
a(8,9) = "0x66"
a(8,10)= "0x3c"

a(9,1) = "0x3c" '数字9
a(9,2) = "0x66"
a(9,3) = "0xc3"
a(9,4) = "0xc3"
a(9,5) = "0x66"
a(9,6) = "0x3c"
a(9,7) = "0x18"
a(9,8) = "0x0c"
a(9,9) = "0x06"
a(9,10)= "0x03"

%>

ASP.NET验证码图片生成器源代码 图像转换技术是验证码生成中不可或缺的一环,它涉及到位图和矢量图的概念以及图像压缩技术,这些技术对验证码的生成和用户体验都有着直接的影响。 阅读详情

相关推荐

asp验证码-带刷新-最简洁的验证码代码

asp验证码,带刷新,代码简洁 验证源码只有55行,超简洁 引用方式: 验证码: 判断页面: <% if trim(session("validateCode")) trim(Request("txt_check")) then ErrorMessage = "请输入正确的验证码" response.write(" alert('"&ErrorMessage&"');location.href='Default.asp' ") response.end end if %>

asp验证码代码 (带刷新)

将以下代码放到一个单独的页面checkcode.asp Option Explicit Response.buffer=true Call Com_CreatValidCode("validateCode") Sub Com_CreatValidCode(pSN) ' 禁止缓存 Response.Expires = -9999 Response.AddHeader "Prag

feiyafei2008的专栏 958

asp验证码源码程序

asp验证码源码,包含前台调用演示 生成的验证码图片较复杂,可直接做实际应用。 应用实例:http://www.symental.com/demo/liuxue/register.htm

ASP验证码源代码

  <%    '------------------    '图片验证码    'netdust    '05-8-29 发布    '以前的图片验证码很容易被破解,所以在其基础上进行改进,即使知道源代码    '也很难破解。    '干扰次数每加一 -> 穷举法的代价提高约100*100倍    '适当设定杂点几率可以有效降低软件识别正确率    '05-12-20 ...

bangzhou5573的博客 438

26种ASP验证码代码

总共26种ASP验证码的代码,后台登陆、 会员登陆等需要验证码时可使用. 各种样式,数字,中文。亲测可用

ASP版验证码源码完整版

验证码(CAPTCHA)是“Completely Automated Public Turing test to tell Computers and Humans Apart”(全自动区分计算机和人类的图灵测试)的缩写,是一种区分用户是计算机和人的公共全自动程序。可以防止:恶意破解密码、刷票、论坛灌水,有效防止某个黑客对某一个特定注册用户用特定程序暴力破解方式进行不断的登陆尝试,实际上是用验证码是现在很多网站通行的方式(比如招商银行的网上个人银行,百度社区),我们利用比较简易的方式实现了这个功能。 图片验证码 'netdust '05-8-29 发布 '以前的图片验证码很容易被破解,所以在其基础上进行改进,即使知道源代码 '也很难破解。 '干扰次数每加一 -> 穷举法的代价提高约100*100倍 '适当设定杂点几率可以有效降低软件识别正确率 '05-12-20 修正了一个错误

ASP验证码的程序及原理

一共4个页面:form.asp; chk.asp; num.asp; count.asp  得到一个随即数字。加密!  解密后成成XBM图片  利用session 判断  form.asp  &lt;%  '### To encrypt/decrypt include this code in your page   '### strMyEncryptedString = EncryptStrin...

weixin_33913377的博客 111

asp图片验证码源码

使用简单,asp图片验证码,内附说明。 在需要显示验证码图片的地方插入代码 <img src="code.asp"> 同时,自动生成session("psn"),表单提交验证session就可以了。

黑马程序员_学习笔记15_asp.net之验证码实现原理初探

---------------------- Windows Phone 7手机开发、.Net培训、期待与您交流! ---------------------- 验证码这个功能的出现是为了 防止暴力机器人 不断的象网站提交注册或登陆,以及发帖信息。 因为 不对用户能够访问到服务器内存(也就是后台处理代码)的路径加以限制的话,那么暴力机器人的这种行为很有可能导致 服务器内存溢出,最终导致服务器

gqsloveaspnetverymu的专栏 470

20多种ASP验证码分析程序源码

【程序老媛出品,必属精品,亲测校正,质量保证】 资源名:20多种ASP验证码分析程序源码 资源类型:程序源代码 源码说明: 20多种ASP验证码 代码完美分析 适合人群:新手及有一定经验的开发人员

手把手教你用DaVinci Configurator配置AUTOSAR SWC接口(含RTE避坑指南)

本文提供了一份基于DaVinci Configurator工具的AUTOSAR软件组件(SWC)接口配置实战指南。文章详细拆解了SR(发送者-接收者)和CS(客户端-服务器)接口的配置流程,并重点分享了运行时环境(RTE)生成阶段在多核部署、数据类型匹配等常见陷阱中的避坑方案与调试技巧,旨在帮助汽车电子工程师高效完成配置并规避错误。

uuu88的博客 547

传智播客asp.net高级视频免费分享

传智播客asp.net高级课程视频下载地址:http://dl.vmall.com/c0rbdhavbx 课程大纲: 【传智播客.Net培训—第十一季asp.net高级】001-状态保持_ViewState.zip 【传智播客.Net培训—第十一季asp.net高级】002-状态保持_ViewState原理.zip 【传智播客.Net培训—第十一季asp.net高级】003-状

leeyaochao的专栏 1793

spark 适配达梦数据库

spark 适配达梦数据库 版本 spark3.0.0 scala2.12.10 DM Database Server 64 V8 步骤一: 引驱动包: SBT方式: "com.dameng" % "Dm8JdbcDriver18" % "8.1.0.157", maven方式: <dependency> <groupId>com.dameng</groupId> <artifactId>Dm8JdbcDriver18</artifac

_@Eva@_的博客 2089

Asp.net 一般处理程序+扩展

最近,在做项目的过程中,用到了很多的一般处理程序,相信你也用到了,但是你真的了解它吗? 介绍:                             一般处理程序的一般是相对于aspx页面来说的,它介于请求与响应之间的处理程序。说白了就是去掉了前台appx HTML 页面的cs部分,什么请求都可以处理,实现IHttpHandler接口。        通过VS2012中创建一

努力+坚持,而且还很年轻 1万+

Vector CANoe VT2516A实战:从硬件连接到CAPL脚本的完整配置指南

本文详细介绍了Vector CANoe VT2516A板卡从硬件连接到CAPL脚本编写的完整配置指南。涵盖硬件接线原则、VT System配置避坑技巧、系统变量创建规范、可视化Panel设计、CAPL脚本调试及典型故障排查案例,帮助工程师快速掌握VT2516A板卡的应用实践,提升汽车电子测试效率。

weixin_30608503的博客 254

从零到一:STM32G431的DSP库集成与FFT实战避坑指南

本文详细介绍了在STM32G431微控制器上集成CMSIS-DSP库并进行FFT实战开发的完整流程。重点解析了通过CubeMX和Keil环境配置DSP库的关键步骤、编译器宏定义陷阱及解决方案,并提供了FFT算法优化、内存管理及常见问题诊断的实用技巧,帮助开发者高效实现嵌入式信号处理应用。

oauth7security的博客 768

【分析最原始验证码生成】HTTP请求处理程序

      我们知道,在ASP.NET中,所有的请求都要进过HttpApplication的处理管道,具体请参见DebugLZQ前面的博文。在服务器处理请求的过程中,实际的请求处理时通过处理程序来完成的,在HttpApplication的第11个事件(PreRequestHandlerExecute)之后,将会调用处理程序来处理请求。       这是很有道理的,因为请求都要经过这个处理管道,但...

weixin_34232744的博客 140

【Docker安装】OpenEuler系统下部署Docker环境

【Docker安装】OpenEuler系统下部署Docker环境

jks212454的博客 4189

细谈asp.net如何处理应用程序-----c#菜鸟日记

2019独角兽企业重金招聘Python工程师标准>>> ...

weixin_34075268的博客 197

四足狗机器人硬件开发技术栈详解

本文系统介绍了四足狗机器人的硬件开发技术,重点分析了五大核心模块:机械结构(骨架设计)、动力系统(关节驱动)、感知系统(环境监测)、控制系统(决策中枢)和电源系统(能源管理)。文章详细阐述了各模块的选型标准、技术要点和协同设计原则,提供了从需求定位到组装调试的完整开发流程,并针对常见问题给出解决方案。随着材料轻量化、模块标准化和AI集成化的发展趋势,四足机器人硬件将向更灵活、更智能的方向演进,为工业巡检、应急救援等场景提供更强大的移动平台支持。

start_up_go的博客 284

手把手教你学simulink(16.2)--基于Simulink的高通滤波器(High-Pass Filter)项目

基于Simulink的高通滤波器(High-Pass Filter)项目的详细实例介绍。这个项目将重点放在高通滤波器的设计、实现和仿真上,帮助你理解和应用高通滤波器在信号处理中的作用。

MHD0815的博客 926
上一篇: 详细解析C++编写的ATM自动取款机模拟程序
下一篇: VC++中用位图平铺填充整个Dlg的背景
goingup
博客等级 码龄22年 52粉丝 158原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值