zoukankan      html  css  js  c++  java
  • Base64和StrToByte

     1 Function Base64Encode(inData As StringAs String
     2     Const Base64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
     3     Dim cOut As String, sOut As String, i As Long
     4     Dim Bytes() As Byte
     5     Dim t As String
     6     Dim iLen As Long
     7     Dim sGroup As String
     8     t = StrConv(inData & "..", vbFromUnicode)
     9     Bytes = t
    10     iLen = UBound(Bytes) - 2
    11     Bytes(iLen + 1= 0
    12     Bytes(iLen + 2= 0
    13     sOut = ""
    14     For i = 0 To iLen Step 3
    15         sGroup = Oct(&H10000 * CLng(Bytes(i)) + &H100 * CLng(Bytes(i + 1)) + Bytes(i + 2))
    16         sGroup = String(8 - Len(sGroup), "0"& sGroup
    17         sOut = sOut + Mid(Base64, CLng("&o" & Mid(sGroup, 12)) + 11+ Mid(Base64, CLng("&o" & Mid(sGroup, 32)) + 11+ Mid(Base64, CLng("&o" & Mid(sGroup, 52)) + 11+ Mid(Base64, CLng("&o" & Mid(sGroup, 72)) + 11)
    18     Next
    19     Select Case iLen Mod 3
    20         Case 0:
    21             sOut = Left(sOut, Len(sOut) - 2+ "=="
    22         Case 1:
    23             sOut = Left(sOut, Len(sOut) - 1+ "="
    24     End Select
    25     Base64Encode = sOut
    26 End Function
    27 
    28 
    29 
    30  'StrToByte  
    31  Function StrToByte(s As String)
    32 Dim Bytes() As Byte
    33 Dim t
    34 = StrConv(s, vbFromUnicode)
    35 Bytes = t
    36 StrToByte = Bytes
    37 End Function 
    38 
    39 
  • 相关阅读:
    Win7。56个进程让我头疼
    bzoj2843极地旅行社
    bzoj2751[HAOI2012]容易题(easy)
    bzoj3442学习小组
    bzoj4423[AMPPZ2013]Bytehattan
    bzoj4591[Shoi2015]超能粒子炮·改
    bzoj2299[HAOI2011]向量
    bzoj3223Tyvj 1729 文艺平衡树
    bzoj2563阿狸和桃子的游戏
    bzoj3673可持久化并查集 by zky&&bzoj3674可持久化并查集加强版
  • 原文地址:https://www.cnblogs.com/xxaxx/p/1635330.html
Copyright © 2011-2022 走看看