Discussion:
base64 corrupt
(too old to reply)
Marshall Fryman
2008-07-22 18:47:42 UTC
Permalink
hello,

I've retrieved a base64 encoded string (supposed to be an image) using Indy
from an HTTPS Post and am now trying to decode the string back to a binary
file. I found an older reference from Remy that basically provided the
following code:

procedure TForm1.Base64ToBinary(var base64: widestring; const filename:
string);
var
SS: TStringStream;
MS: TMemoryStream;
Decoder: TIdDecoderMIME;
begin
SS := TStringStream.Create(base64);
try
MS := TMemoryStream.Create;
try
Decoder := TIdDecoderMIME.Create;
try
Decoder.DecodeBegin(MS);
try
Decoder.Decode(SS);
// SZDecodeBase64(SS,MS);
finally
Decoder.DecodeEnd;
end;
finally
FreeAndNil(Decoder);
end;
finally
MS.SaveToFile(filename);
FreeAndNil(MS);
end;
finally
FreeAndNil(SS);
end;
end;

The problem is that the output is not 100% correct. There are semi-random
sections that match the correct output but not all. If I use SZCodeBaseX it
works fine so I know the base64 string is correct (I also used a straight
conversion tool to make sure it wasn't a bug in SZCodeBaseX that somehow
produced the correct output). Is TIdDecoderMime not supposed to convert any
generic base64 encoded string back to it's original form?

BTW, this is an indy 10 snapshot from a few months ago compiled with D2007.

thanks in advance,
m
Jamie Dale
2008-07-23 00:24:55 UTC
Permalink
Is TIdDecoderMime not supposed to convert any generic base64 encoded
string back to it's original form?
Probably a bug that hasn't been identified. Indy is created and maintained
soley by volunteers... I think the only 2 active coders are now Remy and
Chad... though I kinda get the impression Chad isn't very active these days
but I might be wrong.
BTW, this is an indy 10 snapshot from a few months ago compiled with D2007.
I'm pretty sure Remy will advise you to download the latest snapshot ;)
Jamie Dale
2008-07-23 01:28:33 UTC
Permalink
I think the only 2 active coders are now Remy and Chad...
Chad hasn't been an active coder on Indy for a long time. Me and JP and
Marco are the active coders right now.
3 of you? - Blimey!

What happened to Olaf? - Or was he only part of the web team?
Remy Lebeau (TeamB)
2008-07-23 01:36:21 UTC
Permalink
Post by Jamie Dale
What happened to Olaf? - Or was he only part of the web team?
Olaf doesn't work on Indy coding. He works on IntraWeb, I think. He also
is an admin for Indy's development servers and such.


Gambit
Jamie Dale
2008-07-23 01:41:16 UTC
Permalink
Post by Remy Lebeau (TeamB)
Post by Jamie Dale
What happened to Olaf? - Or was he only part of the web team?
Olaf doesn't work on Indy coding. He works on IntraWeb, I think. He also
is an admin for Indy's development servers and such.
Ah right I see... I remember chatting to him on Skype once and I got the
impression he was one of the coding team for some reason...
Remy Lebeau (TeamB)
2008-07-23 01:17:50 UTC
Permalink
I think the only 2 active coders are now Remy and Chad...
Chad hasn't been an active coder on Indy for a long time. Me and JP and
Marco are the active coders right now.


Gambit
Remy Lebeau (TeamB)
2008-07-23 01:16:48 UTC
Permalink
Post by Marshall Fryman
The problem is that the output is not 100% correct. There are
semi-random sections that match the correct output but not all.
Can you be more specific? What does the actual base64 look like? What does
the output look like? What should it look like?
Post by Marshall Fryman
Is TIdDecoderMime not supposed to convert any generic base64
encoded string back to it's original form?
Yes, it is.


Gambit
Marshall Fryman
2008-07-23 18:26:52 UTC
Permalink
Remy -

I can post my base64 and what not but it has some confidential information.
Could you send me an e-mail address at marshall.fryman_at_gmail.com that I
could send you the info?

thanks,
m
Post by Remy Lebeau (TeamB)
Post by Marshall Fryman
The problem is that the output is not 100% correct. There are
semi-random sections that match the correct output but not all.
Can you be more specific? What does the actual base64 look like? What
does the output look like? What should it look like?
Post by Marshall Fryman
Is TIdDecoderMime not supposed to convert any generic base64
encoded string back to it's original form?
Yes, it is.
Gambit
Remy Lebeau (TeamB)
2008-07-23 18:30:34 UTC
Permalink
Post by Marshall Fryman
I can post my base64 and what not but it has some confidential
information.
Can you come up with different test data that is not confidential but
exhibits the same problem?


Gambit

Continue reading on narkive:
Loading...