Search results for 'MIME Type Encoding'. 1 post(s) found.

  1. 2009/07/16 Base64 Encoding/Decoding function for Delphi
2009/07/16 14:55

Base64 Encoding/Decoding function for Delphi


Base64Encoding function is frequently used in MIME Type based programming. Here's the good resource for supporting Base64Encode and Base64Decode.

uses IdCoder, IdCoder3to4, IdCoderMIME, jpeg;

function Base64Decode(const Text : ansiString): ansiString;
var
  Decoder : TIdDecoderMime;
begin
  Decoder := TIdDecoderMime.Create(nil);
  try
    Result := Decoder.DecodeString(Text);
  finally
    FreeAndNil(Decoder)
  end
end;

function Base64Encode(const Text : ansiString): ansiString;
var
  Encoder : TIdEncoderMime;
begin
  Encoder := TIdEncoderMime.Create(nil);
  try
    Result := Encoder.EncodeString(Text);
  finally
    FreeAndNil(Encoder);
  end
end;

I verified above functions on Delphi 2009.
Trackback 0 Comment 0

Trackback : Cannot send a trackbact to this post.