您正在使用 IPV4 [3.90.33.254] 访问本站,您本次已经查看了 1 页
用户名: 密 码: 验证码:     用QQ登录本站
首页 软件 编程 笑话 知识 公告 台风 日历 计算器
[公益]保护绿色环境,构建和谐社会       悟空收录网      

【腾讯云】 爆款2核2G3M云服务器首年 61元,叠加红包再享折上折      
[公益] 地球是我家,绿化靠大家      
2024年 清明节 007
2024年 劳动节 034
2025年 元 旦 279
2025年 春 节 307
 
您现在的位置:首页 >> ASP/ASP.net >> 内容
本类新增
本类热门
用Asp写个加密和解密的类
内容摘要: classBase64ClassremConstdimsBASE_64_CHARACTERS'转化码dimlenString'计算字符串的长度dimiCount'计数器dimreturnValue'返回值dimtempChar'缓存字符dimtempString'缓存字符串dimparamString'参数字符串dimtemHex'缓存缓存十六进制dimte......
classBase64Class

remConst

dimsBASE_64_CHARACTERS'转化码

dimlenString'计算字符串的长度

dimiCount'计数器

dimreturnValue'返回值

dimtempChar'缓存字符

dimtempString'缓存字符串

dimparamString'参数字符串

dimtemHex'缓存缓存十六进制

dimtempLow'缓存低位

dimtempHigh'缓存高位

dimmod3String'

dimmod4String'

dimtempBinary'

dimtempByteOne'

dimtempByteTwo'

dimtempByteThree'

dimtempByteFour'

dimtempSaveBitsOne'

dimtempSaveBitsTwo'

'********************************************

'begin初始化类

'********************************************

privatesubClass_Initialize()

sBASE_64_CHARACTERS="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"endsub

'********************************************

'end初始化类'

********************************************

'********************************************

'begin销毁类

'********************************************

PrivateSubClass_Terminate()

sBASE_64_CHARACTERS=""endsub

'********************************************

'end销毁类

'********************************************

'********************************************

'begin将Ansi编码的字符串进行Base64编码

'********************************************

publicfunctionEncode(paramString)

tempString=""

returnValue=""

lenString=len(paramString)

iflenString<1then

Encode=returnValue

else

mod3String=lenStringmod3

'补足位数是为了便于计算

ifmod3String>0then

lenString=lenString+3-mod3String

lenString=lenString-3

endif

'*************************begin

foriCount=1tolenStringstep3

tempBinary=Mid(paramString,iCount,3)

'response.writetempBinary

tempByteOne=Asc(Mid(tempBinary,1,1)):tempSaveBitsOne=tempByteOneAnd3

tempByteTwo=Asc(Mid(tempBinary,2,1)):tempSaveBitsTwo=tempByteTwoAnd15

tempChar=Asc(Mid(tempBinary,3,1))

tempByteOne=Mid(sBASE_64_CHARACTERS,((tempByteOneAnd252)4)+1,1)

tempByteTwo=Mid(sBASE_64_CHARACTERS,(((tempByteTwoAnd240)16)Or(tempSaveBitsOne*16)And&HFF)+1,1)

tempByteThree=Mid(sBASE_64_CHARACTERS,(((tempCharAnd192)64)Or(tempSaveBitsTwo*4)And&HFF)+1,1)

tempByteFour=Mid(sBASE_64_CHARACTERS,(tempCharAnd63)+1,1)

tempString=tempByteOne&tempByteTwo&tempByteThree&tempByteFourreturnValue=returnValue&tempStringnext

'*************************end

'*************************begin处理最后剩余的几个字符

ifmod3String>0then

tempBinary=Mid(paramString,iCount,mod3String)

ifmod3String=1then

tempString=tempBinary&Chr(64)&Chr(64)&Chr(64)'用@号补足位数

elsetempString=tempBinary&Chr(64)&Chr(64)'用@号补足位数

endif

returnValue=returnValue&tempString

endif

'*************************end处理最后剩余的几个字符

Encode=returnValueendifendfunction

'********************************************

'end将Ansi编码的字符串进行Base64编码

'********************************************

'********************************************

'end将Base64编码字符串转换成Ansi编码的字符串

'********************************************

publicfunctionDecode(paramString)

tempString=""

returnValue=""

lenString=len(paramString)

iflenString<1then

Decode=returnValue

else

mod4String=lenStringmod4

ifmod4String>0then'字符串长度应当是4的倍数

Decode=returnValue

else'begin判断是不是@号

ifMid(paramString,lenString-1,1)="@"then

mod4String=2

endif

ifMid(paramString,lenString-2,1)="@"then

mod4String=1

endif

'end判断是不是@号

ifmod4String>0then

lenString=lenString-4

endif

'******************************begin

foriCount=1tolenStringstep4

tempString=Mid(paramString,iCount,4)

tempByteOne=InStr(sBASE_64_CHARACTERS,Mid(tempString,1,1))-1

tempByteTwo=InStr(sBASE_64_CHARACTERS,Mid(tempString,2,1))-1

tempByteThree=InStr(sBASE_64_CHARACTERS,Mid(tempString,3,1))-1

tempByteFour=InStr(sBASE_64_CHARACTERS,Mid(tempString,4,1))-1

tempByteOne=Chr(((tempByteTwoAnd48)16)Or(tempByteOne*4)And&HFF)tempByteTwo=""&Chr(((tempByteThreeAnd60)4)Or(tempByteTwo*16)And&HFF)

tempByteThree=Chr((((tempByteThreeAnd3)*64)And&HFF)Or(tempByteFourAnd63))

tempString=tempByteOne&tempByteTwo&tempByteThree

returnValue=returnValue&tempString

next

'******************************end

'处理最后剩余的几个字符

ifmod4String>0then

tempString=left(right(paramString,4),mod4String)

returnValue=returnValue&tempString

endif

Decode=returnValue

endif

endif

endfunction

'********************************************

'end将Base64编码字符串转换成Ansi编码的字符串

'********************************************

endclass

版权声明:本内容来源于互联网,如有侵犯您的版权,请联系站长,本站收到您的信息后将及时处理。
上一篇:asp生成html静态页面不更新的解决办法

 

下一篇:asp中的ckEditor的详细配置小结

发布日期:2022/7/15
手机扫二维码直达本页
发布时间:14:42:07
点  击:13
录  入:齐天大圣
相关文章
Baidu
YiJiaCMS 7.3.8 build231228(MSSQL) 闽ICP备05000814号-1
本空间由腾讯云(轻量应用服务器)提供,Cloudflare提供加速防护
运行时间载入中.....