-
May 4th, 2012, 12:10 PM
#1
[RESOLVED] IXMLDOMDocument::load failed if used encrypted characters
Hi,
It might be an easy solution, but I need help around this issue.
If I load xml file which contains following text. It failed because I am using encrypted characters in Password.
Code:
<?xml version="1.0" encoding="UTF-8"?>
<CONFIGDATA>
<DATABASE>
<DATABASENAME>Symbol</DATABASENAME>
<PRIMARYSERVER>172.27.15.240</PRIMARYSERVER>
<SECONDARYSERVER>172.27.15.240</SECONDARYSERVER>
<USERNAME>admin</USERNAME>
<PASSWORD>uÉ£ë@Å</PASSWORD>
</DATABASE>
</CONFIGDATA>
If I use a plain text in Password element then I can load same file successfully.
I don't know whats kind of encoding I can use for this file or else needs to be fixed to read encrypted characters.
Thanks.
A Person who is polite is given goodness and a person who is away from Politeness is away from Goodness.
NAUMAAN
-
May 4th, 2012, 01:57 PM
#2
Re: IXMLDOMDocument::load failed if used encrypted characters
Do you read it using VC++ code? How?
Victor Nijegorodov
-
May 4th, 2012, 02:26 PM
#3
Re: IXMLDOMDocument::load failed if used encrypted characters
Yes I am reading in Visual Studio 2010 VC++.
Following are the main steps while reading xml file.
As I mentioned earlier, I can read this file successfully if I am using plain characters in password.
Code:
MSXML::IXMLDOMDocument2Ptr m_plDomDocument;
HRESULT hr = _plDomDocument.CreateInstance(__uuidof(DOMDocument60));
_bstr_t bstrFileName;
bstrFileName = sFileName.AllocSysString();
variant_t vResult;
vResult = m_plDomDocument->load(bstrFileName);
// vResult failed if I use encrypted password in xml file
Thanks
A Person who is polite is given goodness and a person who is away from Politeness is away from Goodness.
NAUMAAN
-
May 4th, 2012, 03:21 PM
#4
Re: IXMLDOMDocument::load failed if used encrypted characters
You probably need to html encode the password before storing it in the xml and then decode it after you read the xml.
-
May 4th, 2012, 03:46 PM
#5
Re: IXMLDOMDocument::load failed if used encrypted characters
You mean something like this
Code:
void escape(std::string *data)
{
using boost::algorithm::replace_all;
replace_all(*data, "&", "&");
replace_all(*data, "\"", """);
replace_all(*data, "\'", "'");
replace_all(*data, "<", "<");
replace_all(*data, ">", ">");
}
if I only use £ character in password even then I cannot load my xml file, and its not an escape character.
A Person who is polite is given goodness and a person who is away from Politeness is away from Goodness.
NAUMAAN
-
May 4th, 2012, 05:12 PM
#6
Re: IXMLDOMDocument::load failed if used encrypted characters
Originally Posted by Naumaan
if I only use £ character in password even then I cannot load my xml file, and its not an escape character.
there are many more
see that list
Kurt
-
May 4th, 2012, 05:31 PM
#7
Re: IXMLDOMDocument::load failed if used encrypted characters
Thanks Arjay and Zuk.
Its a huge list, it means these characters are not allowed in XML. I cannot code for all these escape characters and my encrypted password can contain any character. Is there any other way to accomplish this task.
A Person who is polite is given goodness and a person who is away from Politeness is away from Goodness.
NAUMAAN
-
May 4th, 2012, 05:39 PM
#8
Re: IXMLDOMDocument::load failed if used encrypted characters
I would just convert the ascii code of each of the password characters into a hex string.
Kurt
-
May 5th, 2012, 03:32 AM
#9
Re: IXMLDOMDocument::load failed if used encrypted characters
I'm just curious to know that why you need to store the password in .xml file?
-
May 7th, 2012, 10:26 AM
#10
Re: IXMLDOMDocument::load failed if used encrypted characters
Its a requirement from customer.
A Person who is polite is given goodness and a person who is away from Politeness is away from Goodness.
NAUMAAN
-
May 7th, 2012, 12:23 PM
#11
Re: IXMLDOMDocument::load failed if used encrypted characters
Originally Posted by Naumaan
Hi,
It might be an easy solution, but I need help around this issue.
If I load xml file which contains following text. It failed because I am using encrypted characters in Password.
That is what encoding such as Base64 and ASCII85 are supposed to do, and that is give you an ASCII equivalent of binary data.
Please google this, as this is how you solve your problem. You don't just place binary data in text-based files like that.
http://en.wikipedia.org/wiki/Base64
Look at the second paragraph, where it describes the usage of Base64 to store complex data in an XML document.
So the steps you should be taking when creating the XML password field:
Code:
Encrypt password -> Base64 encode encrypted password -> Store in XML
The other way around
Code:
Read Base64 XML password -> Base64decode password -> Decrypt password (if it can be decrypted back to original password)
Regards,
Paul McKenzie
Last edited by Paul McKenzie; May 7th, 2012 at 12:35 PM.
-
May 7th, 2012, 04:50 PM
#12
Re: IXMLDOMDocument::load failed if used encrypted characters
Thanks Paul, It worked for me. I was thinking it might be an issue with XML encoding (How to insert non-english characters in xml file). but found out that there are lot of escape characters. Thanks.
A Person who is polite is given goodness and a person who is away from Politeness is away from Goodness.
NAUMAAN
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|