Decodes a base64-encoded string into an array of Bytes.
Public Declare Function CNV_BytesFromB64Str Lib "diCryptoSys.dll"
(ByRef lpData As Byte, ByVal nDataLen As Long, ByVal strInput As String) As Long
nLen = CNV_BytesFromB64Str(abData(0), nDataLen, strInput)
long __stdcall CNV_BytesFromB64Str(unsigned char *lpOutput, long nOutputLen, const char *szInput);
If successful, the return value is the number of bytes in the decoded array; otherwise it returns a negative error code.
Public Function cnvBytesFromB64Str
(szB64 As String) As Byte()
Or use the in-built method System.Convert.FromBase64String
(less forgiving).
static bvec_t crsysapi::Cnv::FromBase64 (const std::string &s)
static Cnv.frombase64(s)
This uses the base64 encoding scheme from [RFC4648]. Pass a zero value for nOutBytes to find the required maximum possible number of bytes in the output array. The final array may be shorter.
@warning [Changed in v5.2] This function now returns an error if it finds an illegal character in the input string (previously any non-base64 character was just ignored). Whitespace characters (space, TAB, LF, CR, VT, FF) are still allowed and ignored but any other non-base64 characters will cause an error.
Dim strBase64 As String Dim abData() As Byte Dim i As Integer strBase64 = "/ty6mHZUMhA=" ' Convert base64 string to bytes abData = cnvBytesFromB64Str(strBase64) For i = LBound(abData) To UBound(abData) Debug.Print Hex(abData(i)); Next Debug.Print
CNV_B64StrFromBytes
CNV_B64Filter