Base64Decode

The Base64Decode decodes text base64 representation to native binary form.

Base64Encode(sData)

Parameters

sData
Text string to decode to binary form

Return value

If successful, the function returns a safearray with raw binary data. Overwise, returns nothing.

Notes

The function should be used to restore original documents from their base64 representation (as rule, attachments in mail and news internet messages). You call this function subsequently with every string of decoded message. After each calling call the WriteFile method to append the newly decoded data to file, as shown on the example.

Example
This VBScript example reads the text file containing the base64 encoded data, and saves binary data into original file "newfile.jpg"

Set tcpip=CreateObject("SHOTIP.Connection")
Set fs=CreateObject("Scripting.FileSystemObject")

Set h=fs.OpenTextFile("encodedfile.txt")
While not h.AtEndOfStream
	a=tcpip.Base64Decode(h.ReadLine())
	if IsArray(a) then tcpip.WriteFile a,0,UBound(a)+1,"newfile.jpg",True
Wend
h.Close()