<?xml version="1.0" encoding="utf-8" ?>
<?xml-stylesheet type="text/xsl" href="RSS_xslt_style.asp" version="1.0" ?>
<rss version="2.0" xmlns:WebWizForums="http://syndication.webwiz.co.uk/rss_namespace/">
 <channel>
  <title>DevForce Community Forum : Using an Encrypted EntitySet</title>
  <link>http://www.ideablade.com/forum/</link>
  <description>This is an XML content feed of; DevForce Community Forum : DevForce Classic : Using an Encrypted EntitySet</description>
  <pubDate>Fri, 12 Jun 2026 00:16:14 -700</pubDate>
  <lastBuildDate>Wed, 08 Aug 2007 15:53:24 -700</lastBuildDate>
  <docs>http://blogs.law.harvard.edu/tech/rss</docs>
  <generator>Web Wiz Forums 9.69</generator>
  <ttl>360</ttl>
  <WebWizForums:feedURL>www.ideablade.com/forum/RSS_post_feed.asp?TID=363</WebWizForums:feedURL>
  <image>
   <title>DevForce Community Forum</title>
   <url>http://www.ideablade.com/forum/forum_images/IdeaBlade_logo_tm.png</url>
   <link>http://www.ideablade.com/forum/</link>
  </image>
  <item>
   <title>Using an Encrypted EntitySet : A recent Tech Tip called &amp;#034;Saving...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=363&amp;PID=896#896</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=21" rel="nofollow">IdeaBlade</a><br /><strong>Subject:</strong> 363<br /><strong>Posted:</strong> 08-Aug-2007 at 3:53pm<br /><br />A recent Tech Tip called "Saving and Restoring the Cache" briefly covered one method of encrypting the cache.&nbsp; Here's another, better performing, way to save and restore an encrypted cache which takes advantage of stream chaining.&nbsp; This simple example uses DES (remember to use the same key and initialization vector for both encryption and decryption):<DIV>&nbsp;</DIV><DIV><FONT face="Courier New" size=2><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"><FONT color=blue><SPAN style="COLOR: blue"><DIV><FONT color=#0000ff size=2></FONT>&nbsp;</DIV><DIV><FONT color=#0000ff size=2>using</FONT><FONT size=2><FONT color=#000000> System.Security.Cryptography;</FONT></FONT></DIV><DIV><FONT size=2><FONT color=#000000></FONT>&nbsp;</DIV><DIV></FONT>string</SPAN></FONT> fileName = Application.UserAppDataPath + <FONT color=maro&#111;n><SPAN style="COLOR: maro&#111;n"><a href="file://\\MyLocalData.bin" target="_blank">"\\MyLocalData.bin</A>"</SPAN></FONT>;</DIV><DIV></SPAN></FONT><FONT face="Courier New" size=2><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"><FONT color=teal><SPAN style="COLOR: teal">DES</SPAN></FONT> des = <FONT color=teal><SPAN style="COLOR: teal">DES</SPAN></FONT>.Create();</SPAN></FONT></DIV><DIV><FONT face="Courier New" size=2><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"><FONT color=teal><SPAN style="COLOR: teal">DESCryptoServiceProvider</SPAN></FONT> desCSP = n<FONT color=blue><SPAN style="COLOR: blue">ew</SPAN></FONT>&nbsp;<FONT color=teal><SPAN style="COLOR: teal">DESCryptoServiceProvider</SPAN></FONT>();</SPAN></FONT></DIV><DIV><FONT face="Courier New" size=2><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"></SPAN></FONT>&nbsp;</DIV><DIV><FONT face="Courier New" size=2><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"><DIV><strong>To save to an encrypted file:</strong></DIV><DIV>&nbsp;</DIV></SPAN></FONT></DIV><DIV><FONT face="Courier New" size=2><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"><FONT color=teal><SPAN style="COLOR: teal">Stream</SPAN></FONT> fs = <FONT color=blue><SPAN style="COLOR: blue">new</SPAN></FONT> <FONT color=teal><SPAN style="COLOR: teal">FileStream</SPAN></FONT>(fileName, <FONT color=teal><SPAN style="COLOR: teal">FileMode</SPAN></FONT>.Create, <FONT color=teal><SPAN style="COLOR: teal">FileAccess</SPAN></FONT>.Write, <FONT color=teal><SPAN style="COLOR: teal">FileShare</SPAN></FONT>.None);</SPAN></FONT></DIV><DIV><FONT face="Courier New" size=2><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"><FONT color=teal><SPAN style="COLOR: teal">CryptoStream</SPAN></FONT> cs = <FONT color=blue><SPAN style="COLOR: blue">new</SPAN></FONT> <FONT color=teal><SPAN style="COLOR: teal">CryptoStream</SPAN></FONT>(</SPAN></FONT><FONT face="Courier New" size=2><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'">fs, desCSP.CreateEncryptor(des.Key, des.IV), <FONT color=teal><SPAN style="COLOR: teal">CryptoStreamMode</SPAN></FONT>.Write);</SPAN></FONT></DIV><DIV><FONT face="Courier New" size=2><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"></SPAN></FONT>&nbsp;</DIV><DIV><FONT face="Courier New" size=2><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'">mPersistenceManager.SaveEntitySet(cs, <FONT color=blue><SPAN style="COLOR: blue">true</SPAN></FONT>);</SPAN></FONT></DIV><DIV><FONT face="Courier New" size=2><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"></SPAN></FONT>&nbsp;</DIV><DIV><FONT face="Courier New" size=2><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"><strong>And to restore an encrypted file:</strong></SPAN></FONT></DIV><DIV><FONT face="Courier New" size=2><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"><?:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p></SPAN></FONT>&nbsp;</DIV><DIV><FONT face="Courier New" size=2><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"><o:p><FONT face="Courier New" size=2><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"><FONT color=teal><SPAN style="COLOR: teal">Stream</SPAN></FONT>&nbsp;fs = <FONT color=blue><SPAN style="COLOR: blue">new</SPAN></FONT> <FONT color=teal><SPAN style="COLOR: teal">FileStream</SPAN></FONT>(fileName, <FONT color=teal><SPAN style="COLOR: teal">FileMode</SPAN></FONT>.Open, <FONT color=teal><SPAN style="COLOR: teal">FileAccess</SPAN></FONT>.Read, <FONT color=teal><SPAN style="COLOR: teal">FileShare</SPAN></FONT>.Read);</SPAN></FONT></o:p></SPAN></FONT></DIV><DIV><FONT face="Courier New" size=2><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"><o:p><FONT face="Courier New" size=2><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"><FONT color=teal><SPAN style="COLOR: teal">CryptoStream</SPAN></FONT> cs = <FONT color=blue><SPAN style="COLOR: blue">new</SPAN></FONT> <FONT color=teal><SPAN style="COLOR: teal">CryptoStream</SPAN></FONT>(fs, desCSP.CreateDecryptor(des.Key, des.IV), <FONT color=teal><SPAN style="COLOR: teal">CryptoStreamMode</SPAN></FONT>.Read);</SPAN></FONT></o:p></SPAN></FONT></DIV><DIV><FONT face="Courier New" size=2><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"><o:p><FONT face="Courier New" size=2><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"></SPAN></FONT></o:p></SPAN></FONT>&nbsp;</DIV><DIV><FONT face="Courier New" size=2><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"><o:p><FONT face="Courier New" size=2><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'">mPersistenceManager.RestoreEntitySet(cs, <FONT color=teal><SPAN style="COLOR: teal">RestoreStrategy</SPAN></FONT>.Normal, <FONT color=blue><SPAN style="COLOR: blue">true</SPAN></FONT>);<o:p></o:p></SPAN></FONT></DIV><P =Ms&#111;normal><FONT face=Arial color=navy size=2><SPAN style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial"><o:p>&nbsp;</o:p></SPAN></FONT></P></o:p></SPAN></FONT></DIV>]]>
   </description>
   <pubDate>Wed, 08 Aug 2007 15:53:24 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=363&amp;PID=896#896</guid>
  </item> 
 </channel>
</rss>