eduardo12fox
asked on
I need read XML with php and make MD5 result
Hello guys,
I have an xml file. I need to read all the contents of the tags in this xml and make the MD5 result. But I do not know how to do that.
The result of MD5 must be: 25bbb49c00aada5300c0607487 eb54df
Help me please!!
TESTE_XML.xml
I have an xml file. I need to read all the contents of the tags in this xml and make the MD5 result. But I do not know how to do that.
The result of MD5 must be: 25bbb49c00aada5300c0607487
Help me please!!
TESTE_XML.xml
ASKER
You are wrong. The result of your rash is: b2289a42f7e326ac80375f2072 dd7f86
the correct is: 25bbb49c00aada5300c0607487 eb54df
in xml on tag: <ans:hash>25bbb49c00aada53 00c0607487 eb54df</an s:hash>
is only show result correct, if I erase this tag the result with you code not is: 25bbb49c00aada5300c0607487 eb54df is other
the correct is: 25bbb49c00aada5300c0607487
in xml on tag: <ans:hash>25bbb49c00aada53
is only show result correct, if I erase this tag the result with you code not is: 25bbb49c00aada5300c0607487
Apologies, I made a mistake in the first code snippet. This should make more sense!
eb54df.
The md5() string is idempotent, meaning that every time you call md5() with the same input, you get the same output. But "same input" is the key. A variation of even one character in the input string will result in dramatically different md5() results. This variation extends to every single character in the input string, even including invisible whitespace, end-of-line characters, etc. You can read a document into a text editor and save it without any apparent changes, and the editor can turn spaces into tabs, etc. Any change, no matter how small, will cause a different md5() result.
A more common design for message authentication takes the form of something like this (pidgin XML).
So when we see something like this in the XML document, what we really need to know is "what fields were used as the input to the md5()?"
<?php // demo/temp_eduardo.php
/**
* https://www.experts-exchange.com/questions/29027519/I-need-read-XML-with-php-and-make-MD5-result.html
*/
error_reporting(E_ALL);
$url = 'https://filedb.experts-exchange.com/incoming/2017/06_w23/1166541/TESTE_XML.xml';
$txt = file_get_contents($url);
$md5 = md5($txt);
echo $md5;
Now, by way of explanation, let me try to explain why my script may produce a different md5() instead of 25bbb49c00aada5300c0607487The md5() string is idempotent, meaning that every time you call md5() with the same input, you get the same output. But "same input" is the key. A variation of even one character in the input string will result in dramatically different md5() results. This variation extends to every single character in the input string, even including invisible whitespace, end-of-line characters, etc. You can read a document into a text editor and save it without any apparent changes, and the editor can turn spaces into tabs, etc. Any change, no matter how small, will cause a different md5() result.
A more common design for message authentication takes the form of something like this (pidgin XML).
<message>Hello World</message>
<md5string>b10a8db164e0754105b7a99be72e3fe5</md5string>
In this kind of design the message and md5() string are packaged together. When the XML is received, the message is extracted and the md5() string is made from the message. This is compared against the md5() part of the XML document. A match means the message arrived intact.So when we see something like this in the XML document, what we really need to know is "what fields were used as the input to the md5()?"
<ans:hash>25bbb49c00aada5300c0607487eb54df</ans:hash>
ASKER
I understand but how solution you give me? Because I need get correct md5
What are the input fields used to create the md5()? Is there any documentation that describes how the publisher of this XML document created the "ans:hash" value?
ASKER
All fild but the tag <ans:hash></ans:hash> have empty. I put value for you have idea about result. but this tag is empty
ASKER
if you get all field and make md5 result have: 25bbb49c00aada5300c0607487 eb54df
with tag <ans:hash></ans:hash> empty.
This result of MD5 I put after into tag: <ans:hash></ans:hash> Do you understand? :D
with tag <ans:hash></ans:hash> empty.
This result of MD5 I put after into tag: <ans:hash></ans:hash> Do you understand? :D
I think so. Let me experiment with it a bit.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Perfect! Perfect! Solved my problem. Thank you, God bless you. :D
Thanks for the points -- it's a really great question!
https://www.experts-exchange.com/articles/28835/Keeping-Secrets-with-PHP.html
Here's an example.
Open in new window