473,387 Members | 1,863 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Encrypting/Decrypting Connection String

I have my SQL Server connectionstring in my web.config file. I'm scared
that someone will open the file and get my username/password. How do I
encrypt, then decrypt the connection string in the web.config file?
Nov 18 '05 #1
3 6149
User the DP API provided by Microsoft or use the .net crypto api which is
included in the .net framework. Essentally, you will have to write a app
that would encrypt this connection string, then copy and paste it in your
web.config. Then you will have to implement a funciton in your code to
decrypt the string.

"VB Programmer" wrote:
I have my SQL Server connectionstring in my web.config file. I'm scared
that someone will open the file and get my username/password. How do I
encrypt, then decrypt the connection string in the web.config file?

Nov 18 '05 #2
One of the best techniques is to use a trusted connection. That way you
don't need
to list a username or password so there is nothing to hide.
If this is not possible, you can alternately store the username and password
encrypted
in the registry.
Here's more information:
http://msdn.microsoft.com/library/de...itysection.asp

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net

"VB Programmer" <Do*****************@jEmail.com> wrote in message
news:e0**************@tk2msftngp13.phx.gbl...
I have my SQL Server connectionstring in my web.config file. I'm scared
that someone will open the file and get my username/password. How do I
encrypt, then decrypt the connection string in the web.config file?

Nov 18 '05 #3
In addition to Steve's reply you might also find the following valuable -

(How To Store an Encrypted Connection String in the Registry)
http://msdn.microsoft.com/library/en...asp?frame=true

Might I add - there are mixed opinions about web apps accessing registry -
some guys think it's cool, some think it's not. My personal view is - as far
as security goes - that can be worked around in an acceptable manner - the
one issue the above mentioned link doesn't address is - registry is
SLOWWWWWWWW as a world war 2 tank !!!. (Like a WW2 tank .. it took a lot of
cra~p).

But then that can be worked around - it's easy - cache the connectionstring;
and setup a dependency similiar to FileDependecy or SqlDependency; and bingo
you just avoided the last argument against registry - performance.

- Sahil Malik
http://dotnetjunkies.com/weblog/sahilmalik


"Steve C. Orr [MVP, MCSD]" <St***@Orr.net> wrote in message
news:eA**************@tk2msftngp13.phx.gbl...
One of the best techniques is to use a trusted connection. That way you
don't need
to list a username or password so there is nothing to hide.
If this is not possible, you can alternately store the username and
password encrypted
in the registry.
Here's more information:
http://msdn.microsoft.com/library/de...itysection.asp

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net

"VB Programmer" <Do*****************@jEmail.com> wrote in message
news:e0**************@tk2msftngp13.phx.gbl...
I have my SQL Server connectionstring in my web.config file. I'm scared
that someone will open the file and get my username/password. How do I
encrypt, then decrypt the connection string in the web.config file?


Nov 18 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Marshall Dudley | last post by:
I have an application where I need to encrypt a bit of text, and then I need to be able to decrypt it using a customer's key. I want to make sure that the key to decrypt is NOT on the server...
3
by: Piotr | last post by:
MS has published on its sites javascript encoder, which enables "encrypting" javascript code. It allows hiding js code from being seen as a text file. There is a decoder for it, available in the...
0
by: cmrchs | last post by:
Hi, Using the RSA-crypto algorithm in .NET , when actually encrypting/decrypting, all the code samples I ran into always used something like, to encrypt : // create keypair and store in...
4
by: Andy G | last post by:
If users forget there passwords I want to send a link to them through email so they can click on a link and go to a change password page. eBay does this by sending you a url that looks something...
0
by: cmrchs | last post by:
Hi, Using the RSA-crypto algorithm in .NET , when actually encrypting/decrypting, all the code samples I ran into always used something like, to encrypt : ' create keypair and store in...
0
by: Anil Gupte | last post by:
How does one encrypt a Microsoft Access Database and then open that encrypted mdb file using code? I assume only the connection string is different... I have an old document...
2
by: Amar | last post by:
Hi All, I want to insert my password into the mysql database by encrypting it so that I can also retrieve the password. Before I was using sha1() for encrypting password,but it is an one way...
3
by: dfa_geko | last post by:
Hi All, I had a question about encrypting and decrypting XML files using asymmetric keys. I copied some sample code from MSDN, here are the samples: ...
2
by: SeeSharp Bint | last post by:
Visual Studio 2005, dotnet, c#. Microsoft SQL Server. Windows XP forms application. Temporarily, for my database application, I have been storing the various elements of database connection...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.