Search code examples
phpdelphibase64mimeencode

Mime / Base 64 encoding


I need a way to encode a string to Mime/Base64 in Delphi 7 and PHP

These two encoders must be compatible :)


Solution

  • The unit EncdDecd has been included since Delphi 6; below are the Mime compatible base64 functions it contains.

    This cached post from FlexVN (the original post is not always on-line) explains how to do the base64 thing between PHP and Delphi using the EncdDecd unit.

    unit EncdDecd;
    
    interface
    
    uses Classes, SysUtils;
    
    procedure EncodeStream(Input, Output: TStream);
    procedure DecodeStream(Input, Output: TStream);
    function  EncodeString(const Input: string): string;
    function  DecodeString(const Input: string): string;
    
    function  DecodeBase64(const Input: AnsiString): TBytes;
    function  EncodeBase64(const Input: Pointer; Size: Integer): AnsiString;