Sample code for 30+ languages & platforms
B4X

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 B4X Downloads

B4X
Dim success As Boolean = False

Dim bd As ChilkatBinData
bd.Initialize

success = bd.LoadFile("qa_data/jpg/starfish.jpg")
If success = False Then
    Log("Failed to load file.")
    Return
End If


Log(bd.GetEncoded("base64"))

'  If you want mult-line base64:
Log("--")
Log(bd.GetEncoded("base64_mime"))

'  If you want hex..
Log("--")
Log(bd.GetEncoded("hex"))

'  etc..