Sample code for 30+ languages & platforms
DataFlex

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

DataFlex
Use ChilkatAx-win32.pkg

Procedure Test
    Boolean iSuccess
    Handle hoBd
    String sTemp1

    Move False To iSuccess

    Get Create (RefClass(cComChilkatBinData)) To hoBd
    If (Not(IsComObjectCreated(hoBd))) Begin
        Send CreateComObject of hoBd
    End

    Get ComLoadFile Of hoBd "qa_data/jpg/starfish.jpg" To iSuccess
    If (iSuccess = False) Begin
        Showln "Failed to load file."
        Procedure_Return
    End

    Get ComGetEncoded Of hoBd "base64" To sTemp1
    Showln sTemp1

    // If you want mult-line base64:
    Showln "--"
    Get ComGetEncoded Of hoBd "base64_mime" To sTemp1
    Showln sTemp1

    // If you want hex..
    Showln "--"
    Get ComGetEncoded Of hoBd "hex" To sTemp1
    Showln sTemp1

    // etc.


End_Procedure