title: T-sql TRIPLE_DES ENCRYPTION - now I need to decrypt the output text file in c#
body: <p>How do I decrypt triple des encryption the file  in c#. Which namespace?</p>
  
  <p>This is the output file:</p>
  
  <pre>
  FirstCol  secondCol  EncryptSecondCol
  1         value      00E35587C2CCEF4683B98686ED0483480100000054ABDFFB520111778B477223D1CD853F3CE33B4DD96C0F96
  </pre>                                
  
  <p>The sql that I used to create the encrypted file below:</p>
  
  <pre>
  
  --CREATE MASTER KEY
  --ENCRYPTION BY PASSWORD = 'jjvc1234%';
  --GO
  
  ---- Create a test certificate
  --CREATE CERTIFICATE Tasc
  --   WITH SUBJECT = 'Tasc Encryption', 
  --   EXPIRY_DATE = '20301231';
  --GO
  
  --CREATE SYMMETRIC KEY TestTableKey
  --WITH ALGORITHM = TRIPLE_DES ENCRYPTION
  --BY CERTIFICATE Tasc
  --GO
  
  Declare @TestTable table(FirstCol varchar(8),secondCol varchar(100),EncryptSecondCol VARBINARY(256))
  insert into @TestTable 
  values('1','value',null);
  
  --select * from @TestTable 
  
  OPEN SYMMETRIC KEY TestTableKey DECRYPTION
  BY CERTIFICATE Tasc
  UPDATE @TestTable
  SET EncryptSecondCol = ENCRYPTBYKEY(KEY_GUID('TestTableKey'),secondCol)
  
  select * from @TestTable 
  
  --OPEN SYMMETRIC KEY TestTableKey DECRYPTION
  --BY CERTIFICATE Tasc
  --SELECT FirstCol,SecondCol,CONVERT(VARCHAR(50),DECRYPTBYKEY(EncryptSecondCol)) AS DecryptSecondCol
  --FROM @TestTable
  
  
  
  
  --CLOSE SYMMETRIC KEY TestTableKey -- close them drop
  
  --DROP SYMMETRIC KEY TestTableKey
  --GO
  --DROP CERTIFICATE Tasc
  --GO
  --DROP MASTER KEY
  --GO
  
  
  -- BACKUP CERTIFICATE Tasc
  --TO FILE = 'c:\Temp\TestCert.cer'</pre>