[DUG] Brain explosion ! (mime64)

Robert martin rob at chreos.co.nz
Tue Aug 25 14:33:25 NZST 2009


Hi

I have a set of functions (not written by me) that encode and decode 
mime64 data.  I want to take a file and mime64 encrypt it than at a 
later point decrypt it.  However I am having trouble calling the 
functions and there is no help.

Functions

function Base64Encode(const InText: string): string; overload;

function Base64Decode(const InText: string): string; overload;


To do the encode I have the following function

var
    fs          : TFileStream;
    BufferIn    : AnsiString;
begin
    fs := TFileStream.Create(FileName, fmOpenRead);
    try
        fs.Position := 0;

        SetString(BufferIn, nil, fs.Size);
        fs.Read(Pointer(BufferIn)^, fs.Size);
        Result := Base64Encode(BufferIn);
    finally
        fs.Free;
    end;


I use a string list to save the output.  I thought this was working but 
when I come to decode it the system checks and finds it is an invalid 
file (does not divide evenly by 4).  Can anyone see what might be wrong 
with the above?

Cheers
Rob



More information about the Delphi mailing list