CNV_BytesFromB64Str decodes a base64-encoded string into an array of Bytes.
Public Declare Function CNV_BytesFromB64Str Lib "diCrPKI.dll"
(ByRef abData As Byte, ByVal nDataLen As Long, ByVal strB64 As String) As Long
nLen = CNV_BytesFromB64Str(abData(0), nDataLen, strB64)
Byte array suitably dimension to receive output.Long specifying the length of the byte array.String of base64 data to be decoded.
long _stdcall CNV_BytesFromB64Str(unsigned char *output, long out_len, const char *input);
Long: If successful, the return value is the number of bytes in the decoded array;
otherwise it returns a negative error code.
Use the in-built method System.Convert.FromBase64String.
Call the function with an empty array to find the required length.
Public Function cnvBytesFromB64Str(strB64 As String) As Variant
Dim abData() As Byte
Dim nDataLen As Long
Dim nB64Len As Long
cnvBytesFromB64Str = abData
nDataLen = CNV_BytesFromB64Str(0, 0, strB64)
If nDataLen <= 0 Then
Exit Function
End If
ReDim abData(nDataLen - 1)
nDataLen = CNV_BytesFromB64Str(abData(0), nDataLen, strB64)
ReDim Preserve abData(nDataLen - 1)
cnvBytesFromB64Str = abData
End Function
CNV_B64StrFromBytes CNV_B64Filter