У меня есть такой вот модуль
| Код | Option Explicit
Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (Destination As Any, Source As Any, ByVal Length As Long)
Public Function Encode(ByVal iStr As String) As String Dim iXml As New MSXML2.DOMDocument30 Dim iArray() As Byte
With iXml.createElement("Encoder") .dataType = "bin.base64" ReDim iArray(LenB(iStr)) CopyMemory iArray(0), ByVal StrPtr(iStr), LenB(iStr)
.nodeTypedValue = iArray() Encode = .Text End With End Function
Public Function Decode(ByVal iStrbase64 As String) As Byte() Dim strXML As String
strXML = "<DECODER xmlns:dt=" & Chr(34) & "urn:schemas-microsoft-com:datatypes" & Chr(34) & " dt:dt=" & Chr(34) & "bin.base64" & Chr(34) & ">" & iStrbase64 & "</DECODER>" With New MSXML2.DOMDocument30 .loadXML strXML Decode = .selectSingleNode("DECODER").nodeTypedValue End With End Function
Public Function ToHex(ByVal iStr As String) As String Dim iXml As New MSXML2.DOMDocument30 Dim iArray() As Byte
With iXml.createElement("Encoder") .dataType = "bin.hex" ReDim iArray(LenB(iStr)) CopyMemory iArray(0), ByVal StrPtr(iStr), LenB(iStr)
.nodeTypedValue = iArray() ToHex = .Text End With End Function
Public Function FromHex(ByVal iStrbase64 As String) As Byte() Dim strXML As String
strXML = "<DECODER xmlns:dt=" & Chr(34) & "urn:schemas-microsoft-com:datatypes" & Chr(34) & " dt:dt=" & Chr(34) & "bin.hex" & Chr(34) & ">" & iStrbase64 & "</DECODER>" With New MSXML2.DOMDocument30 .loadXML strXML FromHex = .selectSingleNode("DECODER").nodeTypedValue End With End Function
|
Может чем тебе поможет. Хотя бы пример будет... |