Board index » delphi » base64 encode/decode using Indy 9.0

base64 encode/decode using Indy 9.0

Hi!  Anyone has a base64 encoding/decoding sample using IdCoder?  I can't
seem to make it work. :(

Thanks!

 

Re:base64 encode/decode using Indy 9.0


Here is an decoding sample. Just written last night and it seems to work. Maybe it would be faster if the source is also read from a stream, but I am not so fam with streams. Maybe you can rewrite it and send it back.

Regards
Michael

uses IdCoderMIME

Procedure vsDecodeMime(inFileName, outFileName : String );
var
  sl_Source : TStringList;
  fs: TFileStream;
  sub : String;
  i : Integer;
  myMime : TIdDecoderMIME;

begin
  sl_Source := TStringList.Create;
  sl_Source.LoadFromFile(inFileName);
  fs := TFileStream.Create(outFileName, fmCreate);

  myMime := TIdDecoderMIME.Create(Nil);
  try
    for i := 0 to sl_Source.Count -1 do
      begin
        sub := sl_Source[i];
        while (Length(Sub) mod 4) > 0 do sub := sub+'=';
        myMime.DecodeToStream(sub, fs);
    end;
  finally
    myMime.Free;
    fs.Free;
    sl_Source.Free;
  end;
end;

Quote
>Hi!  Anyone has a base64 encoding/decoding sample using IdCoder?  I can't
>seem to make it work. :(

>Thanks!

Other Threads