<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://forums.asp.net/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Security</title><link>http://forums.asp.net/25.aspx</link><description>All about ASP.NET security (authentication, authorization, membership, roles, etc.) and the Login controls. &lt;a href="http://aspadvice.com/SignUp/list.aspx?l=24&amp;c=17" target="_blank"&gt;Email List&lt;/a&gt;</description><dc:language>en</dc:language><generator>CommunityServer 2007 SP1 (Build: 20510.895)</generator><item><title>Re: Can I create a password salt?</title><link>http://forums.asp.net/thread/2409039.aspx</link><pubDate>Sun, 08 Jun 2008 08:55:10 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:2409039</guid><dc:creator>Freakish_05</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/2409039.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=25&amp;PostID=2409039</wfw:commentRss><description>&lt;p&gt;Hi bbaxter,&lt;/p&gt;&lt;p&gt;The following method will create a random salt for you.&amp;nbsp; Assuming you wanted the salt to be one-time per user, this is a very useful method.&lt;br /&gt;&lt;/p&gt;&lt;pre class="coloredcode"&gt;&lt;span class="kwd"&gt;public static string&lt;/span&gt; CreateSalt()&lt;br /&gt;        {&lt;br /&gt;            RNGCryptoServiceProvider rng = &lt;span class="kwd"&gt;new&lt;/span&gt; RNGCryptoServiceProvider();&lt;br /&gt;            &lt;span class="kwd"&gt;byte&lt;/span&gt;[] buff = &lt;span class="kwd"&gt;new byte&lt;/span&gt;[32];&lt;br /&gt;            rng.GetBytes(buff);&lt;br /&gt;            &lt;span class="kwd"&gt;return&lt;/span&gt; Convert.ToBase64String(buff);&lt;br /&gt;        }&lt;/pre&gt;&lt;pre class="coloredcode"&gt;I also encrypt my passwords using the following method.&lt;/pre&gt;&lt;pre class="coloredcode"&gt;&lt;span class="kwd"&gt;public static string&lt;/span&gt; Enc(&lt;span class="kwd"&gt;string&lt;/span&gt; d2e)&lt;br /&gt;        {&lt;br /&gt;            UnicodeEncoding uEncode = &lt;span class="kwd"&gt;new&lt;/span&gt; UnicodeEncoding();&lt;br /&gt;            &lt;span class="kwd"&gt;byte&lt;/span&gt;[] bytD2e = uEncode.GetBytes(d2e);&lt;br /&gt;            SHA256Managed sha = &lt;span class="kwd"&gt;new&lt;/span&gt; SHA256Managed();&lt;br /&gt;            &lt;span class="kwd"&gt;byte&lt;/span&gt;[] hash = sha.ComputeHash(bytD2e);&lt;br /&gt;            &lt;span class="kwd"&gt;return&lt;/span&gt; Convert.ToBase64String(hash);&lt;br /&gt;        }&lt;/pre&gt;&lt;p&gt;Notice that I am using SHA256.&amp;nbsp; You can use SHA1 if you want but there are apparrently some vulnerabilities with it.&amp;nbsp; There&amp;#39;s also SHA384, SHA512 and SHA786 IIRC but as you increase the number, you also increase the time and processor load which will result in performance issues if you have high traffic.&lt;/p&gt;&lt;p&gt;SHA256 is a good comprimise for me since it&amp;#39;s relatively quick and it cannot be decrypted.&amp;nbsp; So even if some lucky person managed to gain access to your database, the data would be no good to them anyway &lt;img src="http://forums.asp.net/emoticons/emotion-2.gif" alt="Big Smile" /&gt;&amp;nbsp; Which has just reminded me!&amp;nbsp; Since you cannot decrypt SHA256, you&amp;#39;ll have to encrypt the submitted password and salt retrieved from the database and compare that to the encryped password in the database when authenticating users.&lt;/p&gt;&lt;p&gt;Hope that helps,&lt;/p&gt;&lt;p&gt;Jason&lt;br /&gt;&amp;nbsp;&lt;/p&gt;</description></item><item><title>Re: Can I create a password salt?</title><link>http://forums.asp.net/thread/2407694.aspx</link><pubDate>Fri, 06 Jun 2008 21:26:41 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:2407694</guid><dc:creator>haoest</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/2407694.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=25&amp;PostID=2407694</wfw:commentRss><description>&lt;p&gt;If you are using MD5 or or something similar, simply changing mypass to mypass2 yields a totally different result. Given that, you can concatenate any constant (e.g. a $ sign), or some variable that is fixed for each account (e.g. username) to the password before calling md5 hash function. &lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;</description></item><item><title>Can I create a password salt?</title><link>http://forums.asp.net/thread/2407501.aspx</link><pubDate>Fri, 06 Jun 2008 19:47:01 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:2407501</guid><dc:creator>bbaxter</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/2407501.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=25&amp;PostID=2407501</wfw:commentRss><description>&lt;p&gt;ok, Here&amp;#39;s my situation: I have a users&amp;#39; password, but I need to hash it and create a salt to insert into the aspnet_membership table. Can I do this manually? If there was a way to do it in SQL that&amp;#39;d be awesome, but thats probably asking too much.&lt;br /&gt;&lt;/p&gt;</description></item></channel></rss>