BVB Source Codes

PeterCMS3 v3.2 Show base64.asp Source code

Return Download PeterCMS3 v3.2: download base64.asp Source code - Download PeterCMS3 v3.2 Source code - Type:.asp
  1. <%
  2. Function ThunderEncode(url)
  3.         //将Unicode编码的字符串进行Base64编码
  4.         Dim thunderPrefix, thunderPosix, thunderTitle, thunderUrl
  5.  
  6.         thunderPrefix = "AA"
  7.         thunderPosix = "ZZ"
  8.         thunderTitle = "thunder://"
  9.  
  10.         thunderUrl = thunderTitle & strAnsi2Unicode(Base64encode(strUnicode2Ansi(thunderPrefix & url & thunderPosix)))
  11.  
  12.         ThunderEncode = thunderUrl
  13. End Function
  14.  
  15. Function strUnicodeLen(asContents)
  16. //计算unicode字符串的Ansi编码的长度
  17.         Dim asContents1, len1, k, i
  18.         asContents1="a"&asContents
  19.         len1=len(asContents1)
  20.         k=0
  21.         for i=1 to len1
  22.                 Dim asc1
  23.                 asc1=asc(mid(asContents1,i,1))
  24.                 if asc1<0 then asc1=65536+asc1
  25.                 if asc1>255 then
  26.                         k=k+2
  27.                 else
  28.                         k=k+1
  29.                 end if
  30.         next
  31.         strUnicodeLen=k-1
  32. End Function
  33.  
  34. Function strUnicode2Ansi(asContents)
  35. //将Unicode编码的字符串,转换成Ansi编码的字符串
  36.         Dim len1, i
  37.         strUnicode2Ansi=""
  38.         len1=len(asContents)
  39.         for i=1 to len1
  40.                 Dim varchar, varasc, varHex, varlow, varhigh
  41.                 varchar=mid(asContents,i,1)
  42.                 varasc=asc(varchar)
  43.                 if varasc<0 then varasc=varasc+65536
  44.                 if varasc>255 then
  45.                         varHex=Hex(varasc)
  46.                         varlow=left(varHex,2)
  47.                         varhigh=right(varHex,2)
  48.                         strUnicode2Ansi=strUnicode2Ansi & chrb("&H" & varlow ) & chrb("&H" & varhigh )
  49.                 else
  50.                         strUnicode2Ansi=strUnicode2Ansi & chrb(varasc)
  51.                 end if
  52.         next
  53. End function
  54.  
  55. Function strAnsi2Unicode(asContents)
  56. //将Ansi编码的字符串,转换成Unicode编码的字符串
  57.         Dim len1, i
  58.         strAnsi2Unicode = ""
  59.         len1=lenb(asContents)
  60.         if len1=0 then exit function
  61.         for i=1 to len1
  62.                 dim varchar, varasc
  63.                 varchar=midb(asContents,i,1)
  64.                 varasc=ascb(varchar)
  65.                 if varasc > 127 then
  66.                         strAnsi2Unicode = strAnsi2Unicode & chr(ascw(midb(asContents,i+1,1) & varchar))
  67.                         i=i+1
  68.                 else
  69.                         strAnsi2Unicode = strAnsi2Unicode & chr(varasc)
  70.                 end if
  71.         next
  72. End function
  73.  
  74. Function Base64encode(asContents)
  75. //将Ansi编码的字符串进行Base64编码
  76. //asContents应当是ANSI编码的字符串(二进制的字符串也可以)
  77.         Dim sBASE_64_CHARACTERS
  78.         sBASE_64_CHARACTERS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
  79.         sBASE_64_CHARACTERS = strUnicode2Ansi(sBASE_64_CHARACTERS)
  80.         Dim lnPosition
  81.         Dim lsResult
  82.         Dim Char1
  83.         Dim Char2
  84.         Dim Char3
  85.         Dim Char4
  86.         Dim Byte1
  87.         Dim Byte2
  88.         Dim Byte3
  89.         Dim SaveBits1
  90.         Dim SaveBits2
  91.         Dim lsGroupBinary
  92.         Dim lsGroup64
  93.         Dim m3,m4,len1,len2
  94.  
  95.         len1=Lenb(asContents)
  96.         if len1<1 then
  97.                 Base64encode=""
  98.                 exit Function
  99.         end if
  100.  
  101.         m3=Len1 Mod 3
  102.         If m3 > 0 Then
  103.         //补足位数是为了便于计算
  104.                 asContents = asContents & String(3-m3, chrb(0))
  105.                 len1=len1+(3-m3)
  106.                 len2=len1-3
  107.         else
  108.                 len2=len1
  109.         end if
  110.  
  111.         lsResult = ""
  112.  
  113.         For lnPosition = 1 To len2 Step 3
  114.                 lsGroup64 = ""
  115.                 lsGroupBinary = Midb(asContents, lnPosition, 3)
  116.                 Byte1 = Ascb(Midb(lsGroupBinary, 1, 1)): SaveBits1 = Byte1 And 3
  117.                 Byte2 = Ascb(Midb(lsGroupBinary, 2, 1)): SaveBits2 = Byte2 And 15
  118.                 Byte3 = Ascb(Midb(lsGroupBinary, 3, 1))
  119.                 Char1 = Midb(sBASE_64_CHARACTERS, ((Byte1 And 252)/4) + 1, 1)
  120.                 Char2 = Midb(sBASE_64_CHARACTERS, (((Byte2 And 240)/16) Or (SaveBits1 * 16) And &HFF) + 1, 1)
  121.                 Char3 = Midb(sBASE_64_CHARACTERS, (((Byte3 And 192)/64) Or (SaveBits2 * 4) And &HFF) + 1, 1)
  122.                 Char4 = Midb(sBASE_64_CHARACTERS, (Byte3 And 63) + 1, 1)
  123.                 lsGroup64 = Char1 & Char2 & Char3 & Char4
  124.                 lsResult = lsResult & lsGroup64
  125.         Next
  126.        
  127.         //处理最后剩余的几个字符
  128.         if M3 > 0 then
  129.                 lsGroup64 = ""
  130.                 lsGroupBinary = Midb(asContents, len2+1, 3)
  131.                 Byte1 = Ascb(Midb(lsGroupBinary, 1, 1)): SaveBits1 = Byte1 And 3
  132.                 Byte2 = Ascb(Midb(lsGroupBinary, 2, 1)): SaveBits2 = Byte2 And 15
  133.                 Byte3 = Ascb(Midb(lsGroupBinary, 3, 1))
  134.                 Char1 = Midb(sBASE_64_CHARACTERS, ((Byte1 And 252)/4) + 1, 1)
  135.                 Char2 = Midb(sBASE_64_CHARACTERS, (((Byte2 And 240)/16) Or (SaveBits1 * 16) And &HFF) + 1, 1)
  136.                 Char3 = Midb(sBASE_64_CHARACTERS, (((Byte3 And 192)/64) Or (SaveBits2 * 4) And &HFF) + 1, 1)
  137.                 if M3=1 then
  138.                         lsGroup64 = Char1 & Char2 & ChrB(61) & ChrB(61) //用=号补足位数
  139.                 else
  140.                         lsGroup64 = Char1 & Char2 & Char3 & ChrB(61) //用=号补足位数
  141.                 end if
  142.                 lsResult = lsResult & lsGroup64
  143.         end if
  144.  
  145.         Base64encode = lsResult
  146. End Function
  147.  
  148. Function Base64decode(asContents)
  149. //将Base64编码字符串转换成Ansi编码的字符串
  150. //asContents应当也是ANSI编码的字符串(二进制的字符串也可以)
  151. Dim sBASE_64_CHARACTERS
  152. sBASE_64_CHARACTERS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
  153. sBASE_64_CHARACTERS = strUnicode2Ansi(sBASE_64_CHARACTERS)
  154.         Dim lsResult
  155.         Dim lnPosition
  156.         Dim lsGroup64, lsGroupBinary
  157.         Dim Char1, Char2, Char3, Char4
  158.         Dim Byte1, Byte2, Byte3
  159.         Dim M4,len1,len2
  160.  
  161.         len1= Lenb(asContents)
  162.         M4 = len1 Mod 4
  163.  
  164.         if len1 < 1 or M4 > 0 then
  165.         //字符串长度应当是4的倍数
  166.                 Base64decode = ""
  167.                 exit Function
  168.         end if
  169.  
  170.         //判断最后一位是不是 = 号
  171.         //判断倒数第二位是不是 = 号
  172.         //这里m4表示最后剩余的需要单独处理的字符个数
  173.         if midb(asContents, len1, 1) = chrb(61) then m4=3
  174.         if midb(asContents, len1-1, 1) = chrb(61) then m4=2
  175.  
  176.         if m4 = 0 then
  177.                 len2=len1
  178.         else
  179.                 len2=len1-4
  180.         end if
  181.  
  182.         For lnPosition = 1 To Len2 Step 4
  183.                 lsGroupBinary = ""
  184.                 lsGroup64 = Midb(asContents, lnPosition, 4)
  185.                 Char1 = InStrb(sBASE_64_CHARACTERS, Midb(lsGroup64, 1, 1)) - 1
  186.                 Char2 = InStrb(sBASE_64_CHARACTERS, Midb(lsGroup64, 2, 1)) - 1
  187.                 Char3 = InStrb(sBASE_64_CHARACTERS, Midb(lsGroup64, 3, 1)) - 1
  188.                 Char4 = InStrb(sBASE_64_CHARACTERS, Midb(lsGroup64, 4, 1)) - 1
  189.                 Byte1 = Chrb(((Char2 And 48)*16) Or (Char1 * 4) And &HFF)
  190.                 Byte2 = lsGroupBinary & Chrb(((Char3 And 60)*4) Or (Char2 * 16) And &HFF)
  191.                 Byte3 = Chrb((((Char3 And 3) * 64) And &HFF) Or (Char4 And 63))
  192.                 lsGroupBinary = Byte1 & Byte2 & Byte3
  193.                 lsResult = lsResult & lsGroupBinary
  194.         Next
  195.  
  196.  
  197.         //处理最后剩余的几个字符
  198.         if M4 > 0 then
  199.                 lsGroupBinary = ""
  200.                 lsGroup64 = Midb(asContents, len2+1, m4) & chrB(65) //chr(65)=A,转换成值为0
  201.                 if M4=2 then
  202.                 //补足4位,是为了便于计算
  203.                         lsGroup64 = lsGroup64 & chrB(65)
  204.                 end if
  205.                 Char1 = InStrb(sBASE_64_CHARACTERS, Midb(lsGroup64, 1, 1)) - 1
  206.                 Char2 = InStrb(sBASE_64_CHARACTERS, Midb(lsGroup64, 2, 1)) - 1
  207.                 Char3 = InStrb(sBASE_64_CHARACTERS, Midb(lsGroup64, 3, 1)) - 1
  208.                 Char4 = InStrb(sBASE_64_CHARACTERS, Midb(lsGroup64, 4, 1)) - 1
  209.                 Byte1 = Chrb(((Char2 And 48)*16) Or (Char1 * 4) And &HFF)
  210.                 Byte2 = lsGroupBinary & Chrb(((Char3 And 60)*4) Or (Char2 * 16) And &HFF)
  211.                 Byte3 = Chrb((((Char3 And 3) * 64) And &HFF) Or (Char4 And 63))
  212.  
  213.                 if M4=2 then
  214.                         lsGroupBinary = Byte1
  215.                 elseif M4=3 then
  216.                         lsGroupBinary = Byte1 & Byte2
  217.                 end if
  218.  
  219.                 lsResult = lsResult & lsGroupBinary
  220.         end if
  221.  
  222.         Base64decode = lsResult
  223. End Function
  224.  
  225.  
  226. %>
downloadbase64.asp Source code - Download PeterCMS3 v3.2 Source code
Related Source Codes/Software:
Subdomain hosting edition v1.9 s taobao, pat - The background site admin 2016-09-21
Imitation green download station perfect version - Before increased | software home page, on the basi... 2016-09-21
C9 v2.1.1 static post system - Program USES ASP + ACC structure design and develo... 2016-09-21
Age design website information management system SDCMS v1.1 SP1 - SDCMS is designed to build the information managem... 2016-09-21
Age design website information management system SDCMS v1.1 SP1 - SDCMS is designed to build the information managem... 2016-09-21
Pcook CMS bubble guest v3.0 SDCMS version - Developed by Asp+Access, and meet the needs of sma... 2016-09-21
Download IT mop stand (with site to download the database ACC) - Background management: http://www.xxx.com/admin/ad... 2016-09-21
Jie Yang v0.6.3 article system - System functions: 1, the system settings A confi... 2016-09-21
Seven VIP jubilee dance CMS management system - The Admin \ Inc \ Mold_Inc Asp 2016-09-21
126oo CMS film station system - This procedure ASP + ACC/ASP + SQL, using new kern... 2016-09-21
CRYENGINE - CRYENGINE is a powerful real-time game development... 2017-06-11
postal - 2017-06-11
reactide - Reactide is the first dedicated IDE for React web ... 2017-06-11
rkt - rkt is a pod-native container engine for Linux. It... 2017-06-11
uWebSockets - Tiny WebSockets https://for... 2017-06-11
realworld - TodoMVC for the RealWorld - Exemplary fullstack Me... 2017-06-11
goreplay - GoReplay is an open-source tool for capturing and ... 2017-06-10
pyenv - Simple Python version management 2017-06-10
redux-saga - An alternative side effect model for Redux apps ... 2017-06-10
angular-starter - 2017-06-10

 Back to top