Sample code for 30+ languages & platforms
Xbase++

Convert any File to Base64 (and back)

Demonstrates how to get the contents of any file as a base64 string, and then write it back.

Chilkat Xbase++ Downloads

Xbase++
LOCAL nSuccess
LOCAL oBd
LOCAL cB64Str
LOCAL oBd2

nSuccess := 0

oBd := CreateObject("Chilkat.BinData")

//  This example will load a PDF and return it as a base64 string.
nSuccess := oBd:LoadFile("qa_data/pdf/helloWorld.pdf")
IF (nSuccess != 1)
    ? "Failed to load file."
    oBd:destroy()
    RETURN
ENDIF

cB64Str := oBd:GetEncoded("base64")
? cB64Str

//  Now write the base64 string back to the binary PDF file:
oBd2 := CreateObject("Chilkat.BinData")
nSuccess := oBd2:AppendEncoded(cB64Str, "base64")
nSuccess := oBd2:WriteFile("qa_output/helloWorld.pdf")

oBd:destroy()
oBd2:destroy()