Is there a simple to know if my connection string is encrypt or not?
I want to know if my connection string is encrypted or not. I don't want to encrypt it again and again. This is only an issue in development stage. Any way to check the status of the connection string in App.config?开发者_开发百科
Why not see if the connection string contains the strings "Source" or "Catalog" (case insensitive)? If so, it is not encrypted. This sure is simple ;-)
Look for the dbname or the likes - you won't find it if it's encrypted.
Isn't the best solution to just check the SectionInformation.IsProtected property?
This is detailed on MSDN and Jon Galloway has a post, Encrypting Passwords in a .NET app.config File, about this as well if you'd like a longer example (some tweaking required).
精彩评论