This is because of how the Base64 encoding deals with long strings.
From RFC 2045 – 6.8 Base64 Content-Transfer-Encoding
The encoded output stream must be represented in lines of no more
than 76 characters each. All line breaks or other characters not
found in Table 1 must be ignored by decoding software. In base64
data, characters other than those in Table 1, line breaks, and other
white space probably indicate a transmission error, about which a
warning message or even a message rejection might be appropriate
under some circumstances.
Because it is adding the vbLf
(Chr(10)
) after the encode should mean you are safe to just remove it using
strEnc = Replace(strEnc, vbLf, "")
Some languages have a “no wrapping” argument that can be passed to stop the Linefeed being added after the 76th character but I don’t know of one in the Microsoft XMLDOM implementation, noted here Base64 — do we really want/need line breaks every 76 characters? it looks as though it was suggested but there is no evidence it was ever implemented.