【VB技巧】VB URL编码与解码 URL加密与解密

  • A+
所属分类:lcx

    VB URL 编码与解码,VB URL 加密与解密,VB URL 编码,VB URL 加密,VB URL 解码,VB URL 解密,VB UrlEncoding,VB URLDecode。

VB URL 编码,VB URL 加密:

Public Function UrlEncoding(StrX As String) As String                           'URL编码
    On Error GoTo over
    Dim I, StrReturn As String, Thischr, Innercode
    StrReturn = ""
    For I = 1 To Len(StrX)
        Thischr = Mid(StrX, I, 1)
        If Abs(Asc(Thischr))
            If Thischr = " " Then
                StrReturn = StrReturn & "+"
            ElseIf InStr("!""#$%&'()*+,/:;[email protected][]^`{|}~%", Thischr) > 0 Then
                StrReturn = StrReturn & "%" & Hex(Asc(Thischr))
            Else
                StrReturn = StrReturn & Thischr
            End If
        Else
            Innercode = Asc(Thischr)
            If Innercode
            StrReturn = StrReturn & "%" & Hex((Innercode And &HFF00) &HFF) & "%" & Hex(Innercode And &HFF)
        End If
    Next
    UrlEncoding = StrReturn
    Exit Function
over:
    UrlEncoding = ""
End Function

VB URL 解码,VB URL 解密:

Public Function URLDecode(ByRef strURL As String) As String                     'URL解码
    Dim I As Long
    If InStr(strURL, "%") = 0 Then URLDecode = strURL: Exit Function
    For I = 1 To Len(strURL)
        If Mid(strURL, I, 1) = "%" Then
            If Val("&H" & Mid(strURL, I + 1, 2)) > 127 Then
                URLDecode = URLDecode & Chr(Val("&H" & Mid(strURL, I + 1, 2) & Mid(strURL, I + 4, 2)))
                I = I + 5
            Else
                URLDecode = URLDecode & Chr(Val("&H" & Mid(strURL, I + 1, 2)))
                I = I + 2
            End If
        Else
            URLDecode = URLDecode & Mid(strURL, I, 1)
        End If
    Next
End Function

文章来源于lcx.cc:【VB技巧】VB URL编码与解码 URL加密与解密

相关推荐: 最近老有垃圾站每天都来采集本站,狗日的!

    --------------------------------------------------------------------------------------------     最近老有垃圾站每天都来采集本站,狗日的!     两个月前…

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: