?
Solved

Illegal XML Char in encrypted string for config file.

Posted on 2007-08-01
10
Medium Priority
?
593 Views
Last Modified: 2010-05-18
I have an encrypted connection string that is giving me fits when I put it into my app.config

Encrtyped string:
?bYk[JwUH0B0[r\]S3V;A]A#1ch8#BNOxZk`"LOiZ`uAK)#/VQ:hS?,=eH/NBQ@eP,<j#_Gh>;0/<uR5fS^=`0b"0+y(}.E\tX:O<`

those illegal chars for <j#_Gh> tend to get in the way.

I saw remarks about using <CDATA[ ] > but that gives a lot of squiggle line in the text file in the IDE.

So how should I go about using this encrypted value?  Do a regex and replace every >< " ' & in my string?  Or is there a cleaner CDATA way that I am missing?

TIA

__Stephen  
0
Comment
Question by:srussell705
  • 5
  • 2
  • 2
  • +1
10 Comments
 
LVL 60

Expert Comment

by:Geert Bormans
ID: 19610378
Hi Stephen,

I would definitely tackle this with CDATA
The correct syntax is     <![CDATA[...]]>
I don't understand your squiggle comment
at the end of the day, CDATA is just a way to escape "'<>& etc.
so as long as you don't have some binary characters in the string, CDATA should fit fine

do a regex is another option, if you don't mind the extra work
< should then become &lt; etc...
but I suppose you know that

cheers

Geert
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 19610450
There is a way, using aspnet_regiis, to encrypt the web.config for ASP.NET web sites.  I wonder if the same or similar technology could be used to encrypt connection strings in an app.config?

Bob
0
 
LVL 1

Author Comment

by:srussell705
ID: 19610640
This is my situation.  It's an app.config file for VB.NET


Existing node and data
<add name="cdFixed"
         connectionString = ?bYk[JwUH0B0[r\]S3V;A]A#1ch8#BNOxZk`"LOiZ`uAK)#/VQ:hS?,=eH/NBQ@eP,<j#_Gh>;0/<uR5fS^=`0b"0+y(}.E\tX:O<`
      providerName="IBM.Data.Informix" />

Where do I put the <![CDATA[ ]]>

This fails:
 <![CDATA[<add name="cdFixed"
      connectionString = ?bYk[JwUH0B0[r\]S3V;A]A#1ch8#BNOxZk`"LOiZ`uAK)#/VQ:hS?,=eH/NBQ@eP,<j#_Gh>;0/<uR5fS^=`0b"0+y(}.E\tX:O<`
    providerName="IBM.Data.Informix"/> ]]>

When I put the CD within the string it fails as well?  

By fail the .NET IDE will show you a red squiggly underline in text that is going to fail.  that was the reference to Squiggly.
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 1

Author Comment

by:srussell705
ID: 19610655
Bob, this is a winform app for one thing not that it matters.  I am given the .dll to decrypt  with the encrypted text that they provide me as well as the seed value.

 
0
 
LVL 60

Expert Comment

by:Geert Bormans
ID: 19610666
CDATA only works on elements, not on attributes
your only option is to escape the faulty characters by regex
cheers
0
 
LVL 1

Author Comment

by:srussell705
ID: 19610745
Thanks Gertone, I was coming to that realization through trial and beating head on monitor.

Well it's time to escape away then, oh is it lunchtime as well.
0
 
LVL 96

Accepted Solution

by:
Bob Learned earned 750 total points
ID: 19611010
Is possible to change the encryption method, or encode the encrypted data with base-64 encoding, so that you don't have special characters?

Bob
0
 
LVL 1

Author Comment

by:srussell705
ID: 19612190
Not sure about changing something here.  I escaped the characters in the string and it seems to work.  Well it kind of did.  

Seems that their krypt.dll cannot handle spaces and informix needs one for user id =  

so I'm generating a byte array but it's 140 elements.  

any better ideas on doing and encryption to string instead?

0
 
LVL 8

Expert Comment

by:harris_c
ID: 19614716
Can you encrypt it using standard .NET encryption before saving it to the config file?

krypt.dll --> yourownencryption --> config
config --> yourowndecryption --> krypt.dll

hec",)
0
 
LVL 1

Author Comment

by:srussell705
ID: 19616966
I found this function in a web search and it worked just fine.

Public Shared Function EncryptString128Bit(ByVal vstrTextToBeEncrypted As String, _
                                        ByVal vstrEncryptionKey As String) As String


I changed the key value to keep it corporate.  

Thanks for all of your help.
0

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

As most anyone who uses or has come across them can attest to, regular expressions (regex) are a complicated bit of magic. Packed so succinctly within their cryptic syntax lies a great deal of power. It's not the "take over the world" kind of power,…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Suggested Courses

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question