婷婷综合国产,91蜜桃婷婷狠狠久久综合9色 ,九九九九九精品,国产综合av

主頁(yè) > 知識(shí)庫(kù) > asp base64加解密函數(shù)代碼

asp base64加解密函數(shù)代碼

熱門標(biāo)簽:長(zhǎng)沙防封電銷卡品牌 騰訊地圖標(biāo)注商戶關(guān)閉 武漢營(yíng)銷電話機(jī)器人軟件 西寧公司外呼系統(tǒng)平臺(tái) 地圖標(biāo)注宅基地 徐州人工智能電銷機(jī)器人好用嗎 智能電銷機(jī)器人適用于哪些行業(yè) 地圖標(biāo)注服務(wù)哪家好 外呼系統(tǒng)還用卡么
復(fù)制代碼 代碼如下:

%

sBASE_64_CHARACTERS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
sBASE_64_CHARACTERS = strUnicode2Ansi(sBASE_64_CHARACTERS)

Function strUnicodeLen(asContents)
'計(jì)算unicode字符串的Ansi編碼的長(zhǎng)度
asContents1="a"asContents
len1=len(asContents1)
k=0
for i=1 to len1
asc1=asc(mid(asContents1,i,1))
if asc10 then asc1=65536+asc1
if asc1>255 then
k=k+2
else
k=k+1
end if
next
strUnicodeLen=k-1
End Function

Function strUnicode2Ansi(asContents)
'將Unicode編碼的字符串,轉(zhuǎn)換成Ansi編碼的字符串
strUnicode2Ansi=""
len1=len(asContents)
for i=1 to len1
varchar=mid(asContents,i,1)
varasc=asc(varchar)
if varasc0 then varasc=varasc+65536
if varasc>255 then
varHex=Hex(varasc)
varlow=left(varHex,2)
varhigh=right(varHex,2)
strUnicode2Ansi=strUnicode2Ansi chrb("H" varlow ) chrb("H" varhigh )
else
strUnicode2Ansi=strUnicode2Ansi chrb(varasc)
end if
next
End function

Function strAnsi2Unicode(asContents)
'將Ansi編碼的字符串,轉(zhuǎn)換成Unicode編碼的字符串
strAnsi2Unicode = ""
len1=lenb(asContents)
if len1=0 then exit function
for i=1 to len1
varchar=midb(asContents,i,1)
varasc=ascb(varchar)
if varasc > 127 then
strAnsi2Unicode = strAnsi2Unicode chr(ascw(midb(asContents,i+1,1) varchar))
i=i+1
else
strAnsi2Unicode = strAnsi2Unicode chr(varasc)
end if
next
End function

Function Base64encode(asContents)
'將Ansi編碼的字符串進(jìn)行Base64編碼
'asContents應(yīng)當(dāng)是ANSI編碼的字符串(二進(jìn)制的字符串也可以)
Dim lnPosition
Dim lsResult
Dim Char1
Dim Char2
Dim Char3
Dim Char4
Dim Byte1
Dim Byte2
Dim Byte3
Dim SaveBits1
Dim SaveBits2
Dim lsGroupBinary
Dim lsGroup64
Dim m4,len1,len2

len1=Lenb(asContents)
if len11 then
Base64encode=""
exit Function
end if

m3=Len1 Mod 3
If M3 > 0 Then asContents = asContents String(3-M3, chrb(0))
'補(bǔ)足位數(shù)是為了便于計(jì)算

IF m3 > 0 THEN
len1=len1+(3-m3)
len2=len1-3
else
len2=len1
end if

lsResult = ""

For lnPosition = 1 To len2 Step 3
lsGroup64 = ""
lsGroupBinary = Midb(asContents, lnPosition, 3)

Byte1 = Ascb(Midb(lsGroupBinary, 1, 1)): SaveBits1 = Byte1 And 3
Byte2 = Ascb(Midb(lsGroupBinary, 2, 1)): SaveBits2 = Byte2 And 15
Byte3 = Ascb(Midb(lsGroupBinary, 3, 1))

Char1 = Midb(sBASE_64_CHARACTERS, ((Byte1 And 252) \ 4) + 1, 1)
Char2 = Midb(sBASE_64_CHARACTERS, (((Byte2 And 240) \ 16) Or (SaveBits1 * 16) And HFF) + 1, 1)
Char3 = Midb(sBASE_64_CHARACTERS, (((Byte3 And 192) \ 64) Or (SaveBits2 * 4) And HFF) + 1, 1)
Char4 = Midb(sBASE_64_CHARACTERS, (Byte3 And 63) + 1, 1)
lsGroup64 = Char1 Char2 Char3 Char4

lsResult = lsResult lsGroup64
Next

'處理最后剩余的幾個(gè)字符
if M3 > 0 then
lsGroup64 = ""
lsGroupBinary = Midb(asContents, len2+1, 3)

Byte1 = Ascb(Midb(lsGroupBinary, 1, 1)): SaveBits1 = Byte1 And 3
Byte2 = Ascb(Midb(lsGroupBinary, 2, 1)): SaveBits2 = Byte2 And 15
Byte3 = Ascb(Midb(lsGroupBinary, 3, 1))

Char1 = Midb(sBASE_64_CHARACTERS, ((Byte1 And 252) \ 4) + 1, 1)
Char2 = Midb(sBASE_64_CHARACTERS, (((Byte2 And 240) \ 16) Or (SaveBits1 * 16) And HFF) + 1, 1)
Char3 = Midb(sBASE_64_CHARACTERS, (((Byte3 And 192) \ 64) Or (SaveBits2 * 4) And HFF) + 1, 1)

if M3=1 then
lsGroup64 = Char1 Char2 ChrB(61) ChrB(61) '用=號(hào)補(bǔ)足位數(shù)
else
lsGroup64 = Char1 Char2 Char3 ChrB(61) '用=號(hào)補(bǔ)足位數(shù)
end if

lsResult = lsResult lsGroup64
end if

Base64encode = lsResult

End Function


Function Base64decode(asContents)
'將Base64編碼字符串轉(zhuǎn)換成Ansi編碼的字符串
'asContents應(yīng)當(dāng)也是ANSI編碼的字符串(二進(jìn)制的字符串也可以)
Dim lsResult
Dim lnPosition
Dim lsGroup64, lsGroupBinary
Dim Char1, Char2, Char3, Char4
Dim Byte1, Byte2, Byte3
Dim M4,len1,len2

len1= Lenb(asContents)
M4 = len1 Mod 4

if len1 1 or M4 > 0 then
'字符串長(zhǎng)度應(yīng)當(dāng)是4的倍數(shù)
Base64decode = ""
exit Function
end if

'判斷最后一位是不是 = 號(hào)
'判斷倒數(shù)第二位是不是 = 號(hào)
'這里m4表示最后剩余的需要單獨(dú)處理的字符個(gè)數(shù)
if midb(asContents, len1, 1) = chrb(61) then m4=3
if midb(asContents, len1-1, 1) = chrb(61) then m4=2

if m4 = 0 then
len2=len1
else
len2=len1-4
end if

For lnPosition = 1 To Len2 Step 4
lsGroupBinary = ""
lsGroup64 = Midb(asContents, lnPosition, 4)
Char1 = InStrb(sBASE_64_CHARACTERS, Midb(lsGroup64, 1, 1)) - 1
Char2 = InStrb(sBASE_64_CHARACTERS, Midb(lsGroup64, 2, 1)) - 1
Char3 = InStrb(sBASE_64_CHARACTERS, Midb(lsGroup64, 3, 1)) - 1
Char4 = InStrb(sBASE_64_CHARACTERS, Midb(lsGroup64, 4, 1)) - 1
Byte1 = Chrb(((Char2 And 48) \ 16) Or (Char1 * 4) And HFF)
Byte2 = lsGroupBinary Chrb(((Char3 And 60) \ 4) Or (Char2 * 16) And HFF)
Byte3 = Chrb((((Char3 And 3) * 64) And HFF) Or (Char4 And 63))
lsGroupBinary = Byte1 Byte2 Byte3

lsResult = lsResult lsGroupBinary
Next

'處理最后剩余的幾個(gè)字符
if M4 > 0 then
lsGroupBinary = ""
lsGroup64 = Midb(asContents, len2+1, m4) chrB(65) 'chr(65)=A,轉(zhuǎn)換成值為0
if M4=2 then '補(bǔ)足4位,是為了便于計(jì)算
lsGroup64 = lsGroup64 chrB(65)
end if
Char1 = InStrb(sBASE_64_CHARACTERS, Midb(lsGroup64, 1, 1)) - 1
Char2 = InStrb(sBASE_64_CHARACTERS, Midb(lsGroup64, 2, 1)) - 1
Char3 = InStrb(sBASE_64_CHARACTERS, Midb(lsGroup64, 3, 1)) - 1
Char4 = InStrb(sBASE_64_CHARACTERS, Midb(lsGroup64, 4, 1)) - 1
Byte1 = Chrb(((Char2 And 48) \ 16) Or (Char1 * 4) And HFF)
Byte2 = lsGroupBinary Chrb(((Char3 And 60) \ 4) Or (Char2 * 16) And HFF)
Byte3 = Chrb((((Char3 And 3) * 64) And HFF) Or (Char4 And 63))

if M4=2 then
lsGroupBinary = Byte1
elseif M4=3 then
lsGroupBinary = Byte1 Byte2
end if

lsResult = lsResult lsGroupBinary
end if

Base64decode = lsResult

End Function
%>

您可能感興趣的文章:
  • 使用 certutil 實(shí)現(xiàn) Hex2Bin 和 Base64 加解密的方法
  • ASP BASE64加解密(親測(cè)可用)
  • Base64加解密的實(shí)現(xiàn)方式實(shí)例詳解

標(biāo)簽:荊門 雅安 普洱 通遼 運(yùn)城 鷹潭 巴彥淖爾 通化

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《asp base64加解密函數(shù)代碼》,本文關(guān)鍵詞  asp,base64,加,解密,函數(shù),代碼,;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問(wèn)題,煩請(qǐng)?zhí)峁┫嚓P(guān)信息告之我們,我們將及時(shí)溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無(wú)關(guān)。
  • 相關(guān)文章
  • 下面列出與本文章《asp base64加解密函數(shù)代碼》相關(guān)的同類信息!
  • 本頁(yè)收集關(guān)于asp base64加解密函數(shù)代碼的相關(guān)信息資訊供網(wǎng)民參考!
  • 推薦文章
    主站蜘蛛池模板: 英山县| 铅山县| 财经| 临清市| 清丰县| 宁晋县| 苏尼特右旗| 甘泉县| 海淀区| 略阳县| 姜堰市| 嫩江县| 辽宁省| 修水县| 新乡市| 麟游县| 石嘴山市| 延安市| 仁化县| 射阳县| 永仁县| 罗源县| 阿合奇县| 姚安县| 宁阳县| 盱眙县| 曲周县| 宣武区| 黄冈市| 寿光市| 内江市| 原平市| 错那县| 宝丰县| 聂荣县| 泸州市| 揭阳市| 麻栗坡县| 浦县| 黄冈市| 遂昌县|