title: Encryption from c# application
body: <p>SITUATION:
  I need to make encryption happen between my remote database and my c# application. I don't know what I'm doing (never done any encryption before) and all the stuff I found on the web was for asp.net and dealt with the web.config file.</p>
  <p>SOME RELEVANT DATA:
  My connection string contains password info for SQL server authentication, there is a select, and a delete statement. Those three things will need to be encrypted.</p>
  <p>I am using SQL Server 2008, Visual Studio 2008, and C#.</p>
  <p>I doubt this is relevant but this is taking place inside a windows service. So far, anything SQL related that works in winForms has worked for me in services, so any help that is winForms related is appreciated, too.</p>
  <p>WHAT I NEED HELP ON:</p>
  <ol>
  <li><p>Any references on encryption that aren't restricted to asp.net would be greatly appreciated. :)</p>
  </li>
  <li><p>I see the <a href="https://docs.microsoft.com/en-us/dotnet/api/system.security.cryptography.rsacryptoserviceprovider?view=net-6.0" rel="nofollow noreferrer">MSDN page</a>, and it seems like a decent place to start, but I am a little confused. It seems like this is the way 2 applications would send a file to each other, rather than sending something encrypted to SQL Server? Using this, I don't see how SQL Server would know how to decrypt it?</p>
  </li>
  <li><p>Am I way out in left field looking in System.Security.Cryptography? Is there some way to specify encryption within System.Data.SqlClient or am I going to have to resort to messing around making stored procedures on the remote server?</p>
  </li>
  </ol>
  <p>Thank you in advance!!! :)</p>
  <p>SUMMARY:</p>
  <p>Thank you all for setting me on the right path, it was difficult to choose just one answer! :)</p>
  <p>I've concluded that I need to use SSL, and while I yet have a lot of confusion about the how-tos, I know that this requires a certificate, and that once the certificate is set up, the client can request encryption by asking for &quot;Encrypt=yes&quot; in the connection string. Luckily I believe I already have one I can use.</p>
  <p>Another thing to note - TDE is the consensus on what is good for encrypting data that is just sitting in the database, while SSL is what to use for transmitting encrypted data.</p>
  <p>Here were a couple links I found the most helpful:</p>
  <p><a href="https://web.archive.org/web/20151122032745/http://blogs.msdn.com:80/b/sql_protocols/archive/2005/10/04/476705.aspx" rel="nofollow noreferrer">Link</a></p>
  <p><a href="http://support.microsoft.com/default.aspx?scid=kb;en-us;316898" rel="nofollow noreferrer">http://support.microsoft.com/default.aspx?scid=kb;en-us;316898</a></p>