hiding/encrypting connection string
-
hi all i am deploying an asp.net application and i want to prevent users from seeing my connection string. I want to hide my user name and password. I googled a little but there is no clear example that i found. I only found theories. Any help with some code, url.. any thing that closes the encryption idea or what ever called to me. thanks in advance.
-
hi all i am deploying an asp.net application and i want to prevent users from seeing my connection string. I want to hide my user name and password. I googled a little but there is no clear example that i found. I only found theories. Any help with some code, url.. any thing that closes the encryption idea or what ever called to me. thanks in advance.
Hi, Use the following code to encrypt and decrypt your connection string. public static byte[] Encrypt(byte[] clearData, byte[] Key, byte[] IV) { //create the memory stream MemoryStream ms = new MemoryStream(); //create a crypto service provider Rijndael objrj = Rijndael.Create(); //set the Key and iV values objrj.Key = Key; objrj.IV = IV; //create a crypto ctream CryptoStream cs = new CryptoStream(ms,objrj.CreateEncryptor(),CryptoStreamMode.Write); cs.Write(clearData,0,clearData.Length); cs.Close(); byte[] encryptedData = ms.ToArray(); return encryptedData; } public static byte[] Decrypt(byte[] cypherData, byte[] Key, byte[] IV) { //create the memory stream MemoryStream ms = new MemoryStream(); //create a crypto service provider Rijndael objrj = Rijndael.Create(); //set the Key and iV values objrj.Key = Key; objrj.IV = IV; //create a crypto ctream CryptoStream cs = new CryptoStream(ms,objrj.CreateDecryptor(),CryptoStreamMode.Write); cs.Write(cypherData,0,cypherData.Length); cs.Close(); byte[] clearData = ms.ToArray(); return clearData; }