Sample code for 30+ languages & platforms
Xbase++

Get Contents of File as Base64

See more Encryption Examples

Demonstrates how to read the contents of a file and convert to a base64 string.

Chilkat Xbase++ Downloads

Xbase++
LOCAL nSuccess
LOCAL oBd

nSuccess := 0

oBd := CreateObject("Chilkat.BinData")

nSuccess := oBd:LoadFile("qa_data/jpg/starfish.jpg")
IF (nSuccess == 0)
    ? "Failed to load file."
    oBd:destroy()
    RETURN
ENDIF

? oBd:GetEncoded("base64")

//  If you want mult-line base64:
? "--"
? oBd:GetEncoded("base64_mime")

//  If you want hex..
? "--"
? oBd:GetEncoded("hex")

//  etc..

oBd:destroy()