Defect #609
Issue with "wrong" checksums on jpg File
0%
Description
I'm not sure whether this is a bug or whether I'm just doing something wrong in my code, however I get a "wrong" md5 Checksum when doing the following:
var image_byte_array = plugins.http.getMediaData("http://localhost/test.jpg");
var md5_checksum = plugins.it2be_cryptor.MD5;
application.output(md5_checksum);
Running "md5 test.jpg" or "openssl md5 test.jpg" from console - or whatever other md5 calculation tool - all return (the same) different md5 checksum than Cryptor...
Any help with this would be greately appreciated...
-> It's the same for SHA by the way...
Cheers,
Andreas
History
Updated by Jay Cee over 12 years ago
Hmmm seems this Editor made some of the code disappear: This is the actual code:
var image_byte_array = plugins.http.getMediaData("http://localhost/test.jpg");
var md5_checksum = plugins.it2be_cryptor.MD5(image_byte_array);
application.output(md5_checksum);
Updated by Servoy Components over 12 years ago
- Status changed from Feedback to In Progress
The Plug-in performs a base64 encoding first.
Hope this helps.
Updated by Jay Cee over 12 years ago
Hi Marcel,
thanks for your reply.
I see - then something else is weird:
openssl enc -base64 -in test.jpg | openssl md5
again returns different checksums than Cryptor
I had a look what happened after the base64 encoding:
These are the first 2 lines of what your plugin puts out:
/9j/4AAQSkZJRgABAQEASABIAAD/2wBDAAgGBgcGBQgHBwcJCQgKDBQNDAsLDBkSEw8UHRofHh0a
HBwgJC4nICIsIxwcKDcpLDAxNDQ0Hyc5PTgyPC4zNDL/2wBDAQkJCQwLDBgNDRgyIRwhMjIyMjIy
...
And this is what happened when I ran "openssl enc -base64 -in test.jpg"
/9j/4AAQSkZJRgABAQEASABIAAD/2wBDAAgGBgcGBQgHBwcJCQgKDBQNDAsLDBkS
Ew8UHRofHh0aHBwgJC4nICIsIxwcKDcpLDAxNDQ0Hyc5PTgyPC4zNDL/2wBDAQkJ
...
->The line length isn't identical so all chechksums are different again...
Any help with this... sorry to bother you but could you maybe provide some short code how to do this properly in Servoy?
Cheers,
Andreas