Hi Leandro,

thank you for reporting. I can't believe it is wrong again, but its true. I recently fixed already a bug. I have to check it.

Tommi

Am 26.04.2012 16:38, schrieb Leandro Santiago:
Hello. I was testing the base64stream and I realized it doesn't work
correctly with binary data. The unit test used in cxxtools source is
applied only with small ascii strings.

I'm sending an example which reproduces the error. first I calculated
the expected base64 string of an image (attached) with the command
line
$ base64 -w0<  test_image.jpg # I also tested with the mono (c#)
base64 package having the same correct results

I tested it in two intel machines with ubuntu and compiled with gcc.
One is 32-bit and another is 64-bit. The problem happens in both.

The expected string os the example is:

/9j/4AAQSkZJRgABAQEASABIAAD//gANTGF2YzUzLjQyLjT/2wBDAAUDBAQEAwUEBAQFBQUGBwwIBwcHBw8LCwkMEQ8SEhEPERETFhwXExQaFRERGCEYGh0dHx8fExciJCIeJBweHx7/2wBDAQUFBQcGBw4ICA4eFBEUHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh7/wAARCAASABcDASIAAhEBAxEB/8QAGAABAQEBAQAAAAAAAAAAAAAAAAIEAwf/xAAhEAABBAEDBQAAAAAAAAAAAAAAAQIDEiEEESITMTJCQ//EABcBAQEBAQAAAAAAAAAAAAAAAAACAQT/xAAVEQEBAAAAAAAAAAAAAAAAAAAAEf/aAAwDAQACEQMRAD8A9F6teW2fUyvlzmpE7stQmt12edMFSamNqefIEyxRurgGDTMiHH7MAKB/YAEj/9k=

But the result, via Base64Stream is:

/tf/4AAQSkZJRgABAQEASABIAA///gANTGF2YzUzLjQyLjP/2wBDAAUDBAQEAwUEBAQFBQUGBwwIBwcHBw8LCwkMEQ8SEhEPERETFhwXExQaFRERGCEYGh0dHx8fExciJCIeJBweHx3/2wBDAQUFBQcGBw4ICA4eFBEUHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh3/wAARCAASABcDASIAAhEBAxEB/sQAGAABAQEBAQAAAAAAAAAAAAAAAAIEAwb/xAAhEAABBAEDBQAAAAAAAAAAAAAAAQIDEiEEESITMTJCQv7EABcBAQEBAQAAAAAAAAAAAAAAAAACAQP/xAAVEQEBAAAAAAAAAAAAAAAAAAAAEP7aAAwDAQACEQMRAD8A9F2teWyfUyrlzmpE7ctQmd12eNMFSKiNqObIEyxRubgGDTMiHH3MA6B/YAEj/tk=

The two strings are very close (they also have same lenght), but there
are some different characters.

I'm also sending a simple program in c# (i tested with mono on linux)
which does the correct encoding. It receives the binary file as
parameter and prints the base64 string on sceren.

$ cli-csc Main.cs
$ mono Main.exe test_image.jpg

Thanks in advance



------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/


_______________________________________________
Tntnet-general mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tntnet-general

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Tntnet-general mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tntnet-general

Reply via email to