Connecting Tech Pros Worldwide Help | Site Map

PasswordEncryption

Newbie
 
Join Date: Nov 2008
Posts: 1
#1: Nov 14 '08
Hi,

This is Nagamani. I have to encrypt the password in the connection string while connecting to SQL Server 2005 Database.And later I have to decrypt. I am using C#.net with Visual Studio 2008.


Please help me on this.
PRR PRR is offline
Moderator
 
Join Date: Dec 2007
Location: India
Posts: 700
#2: Nov 14 '08

re: PasswordEncryption


You should look into System.Security.Cryptography namespace...


Expand|Select|Wrap|Line Numbers
  1. using System.Web.Configuration;
  2. Configuration config = WebConfigurationManager.
  3.         OpenWebConfiguration("~");
  4.  
  5.         // Get the connectionStrings section.
  6.         ConnectionStringsSection constr =
  7.             config.GetSection("connectionStrings")
  8.             as ConnectionStringsSection;
  9.  
  10.         if (constr != null)
  11.         {
  12.             if (constr.SectionInformation.IsProtected)
  13.             {
  14.                 constr.SectionInformation.UnprotectSection();
  15.             }
  16.             Label1.Text = string.Empty+ constr.ConnectionStrings[0].ToString();
  17.  
  18.             string ss = constr.ConnectionStrings[0].ToString();
  19.  
  20.  
  21.         }
  22.  
  23.  
  24.         {
  25.  
  26.             constr.SectionInformation.ProtectSection(
  27.                 "DataProtectionConfigurationProvider");
  28. //RsaProtectedConfigurationProvider
  29.  
  30.             constr.SectionInformation.ForceSave = true;
  31.  
  32.             config.Save(ConfigurationSaveMode.Full);
  33.  
  34.         }
  35.  
Lives Here
 
Join Date: Sep 2006
Posts: 12,070
#3: Nov 14 '08

re: PasswordEncryption


1) Web application or desktop application?
2.) Where does the password come from?
3.) For a simple DES check out the System.Security.Cryptography name space. You can find examples of how to use it all over internet.

Edit: Looks like DeepBlue's keyboard is faster than mine.
PRR PRR is offline
Moderator
 
Join Date: Dec 2007
Location: India
Posts: 700
#4: Nov 14 '08

re: PasswordEncryption


Take a look at this RsaProtectedConfigurationProvider

r035198x,
"Edit: Looks like DeepBlue's keyboard is faster than mine."
lol.. well not exactly ...
Lives Here
 
Join Date: Sep 2006
Posts: 12,070
#5: Nov 14 '08

re: PasswordEncryption


@DeepBlue, do you by any chance know any chess?
PRR PRR is offline
Moderator
 
Join Date: Dec 2007
Location: India
Posts: 700
#6: Nov 21 '08

re: PasswordEncryption


Quote:

Originally Posted by r035198x

@DeepBlue, do you by any chance know any chess?

i used to play... becoz of my name? "deepblue"? too horrible player though ...
Lives Here
 
Join Date: Sep 2006
Posts: 12,070
#7: Nov 21 '08

re: PasswordEncryption


Quote:

Originally Posted by DeepBlue

i used to play... becoz of my name? "deepblue"? too horrible player though ...

You are therefore are not worth challenging to a game.
I only play against very good players.

r035198x <------- Almost a grand master.
PRR PRR is offline
Moderator
 
Join Date: Dec 2007
Location: India
Posts: 700
#8: Nov 21 '08

re: PasswordEncryption


Quote:

Originally Posted by r035198x

You are therefore are not worth challenging to a game.
I only play against very good players.

r035198x <------- Almost a grand master.

hmm perhaps i could learn from you....
Lives Here
 
Join Date: Sep 2006
Posts: 12,070
#9: Nov 21 '08

re: PasswordEncryption


Most of my opponents ended up on their knees begging for mercy.

http://bytes.com/forum/thread578342-chess.html
PRR PRR is offline
Moderator
 
Join Date: Dec 2007
Location: India
Posts: 700
#10: Nov 21 '08

re: PasswordEncryption


Quote:

Originally Posted by r035198x

Most of my opponents ended up on their knees begging for mercy.

http://bytes.com/forum/thread578342-chess.html

you are too ... way too good for me ....
Reply


Similar .NET Framework bytes