Delphi 7 - Decode Base64 Using TIdDecoderMIME

Well, that turns me on, lol.

I have a Base64 string and am trying to decode it in a TMemoryStream using TIdDecoderMIME.

My current code is as follows:

Var MStream:TMemoryStream; Decoder:TIdDecoderMIME;
begin
  Decoder := TIdDecoderMIME.Create(nil);
  MStream := TMemoryStream.Create;
  Decoder.DecodeToStream(BSting,MStream);
end;

Where is the string BString = My Base64.

Now that the code is running, the "Uneven Size in DecodeToString" error message appears.

Any ideas?

Any help is appreciated. Thank.

+5
source share
2 answers

You pass a DecodeToStreamBase64 string whose length is not a multiple of 4 to the function . In other words, the string you pass in is invalid.

+4
source

Base64 strings are usually padded with "=" characters to make sure their length is a multiple of 4.

, . . StackOverflow " "=" base64

TIdDecoderMime , , 4 - , .

+1

All Articles