Sample code for 30+ languages & platforms
DataFlex

Base64 Encode a File

_LANGUAGE_ to Base64 encode the contents of a file.

Chilkat DataFlex Downloads

DataFlex
Use ChilkatAx-win32.pkg

Procedure Test
    Boolean iSuccess
    Handle hoFac
    String sStrBase64
    String sTemp1
    Boolean bTemp1

    Move False To iSuccess

    // Get the contents of a file into a base64 encoded string:
    Get Create (RefClass(cComCkFileAccess)) To hoFac
    If (Not(IsComObjectCreated(hoFac))) Begin
        Send CreateComObject of hoFac
    End
    Get ComReadBinaryToEncoded Of hoFac "c:/data/something.pdf" "base64" To sStrBase64
    Get ComLastMethodSuccess Of hoFac To bTemp1
    If (bTemp1 <> True) Begin
        Get ComLastErrorText Of hoFac To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    // Now write the string to a file:
    Get ComWriteEntireTextFile Of hoFac "c:/data/something_pdf_base64.txt" sStrBase64 "us-ascii" False To iSuccess
    If (iSuccess <> True) Begin
        Get ComLastErrorText Of hoFac To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    Showln "Success!"


End_Procedure