<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Geekality &#187; Hashing</title>
	<atom:link href="http://www.geekality.net/tag/hashing/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.geekality.net</link>
	<description>With a hint of Social Ineptitude</description>
	<lastBuildDate>Sun, 05 Feb 2012 17:53:50 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>C#: Handy BCrypt class for hashing passwords</title>
		<link>http://www.geekality.net/2009/03/02/a-nice-class-for-hashing/</link>
		<comments>http://www.geekality.net/2009/03/02/a-nice-class-for-hashing/#comments</comments>
		<pubDate>Mon, 02 Mar 2009 10:31:45 +0000</pubDate>
		<dc:creator>Torleif</dc:creator>
				<category><![CDATA[Software Development]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Hashing]]></category>

		<guid isPermaLink="false">http://www.geekality.net/?p=33</guid>
		<description><![CDATA[I was working on an application where I needed to store user names and passwords in a database, as we often do. As we all (should) know we never (ever, ever) store passwords in plain text. If we do, we &#8230; <a href="http://www.geekality.net/2009/03/02/a-nice-class-for-hashing/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I was working on an application where I needed to store user names and passwords in a database, as we often do. As we all (should) know we never (ever, ever) store passwords in plain text. If we do, we are setting ourselves up for big trouble if the database contents leaks out or someone hacks their way into it. So what should you do?</p>
<p>You should <a href="http://en.wikipedia.org/wiki/Salt_(cryptography)">salt</a> the passwords and you should <a href="http://en.wikipedia.org/wiki/Cryptographic_hash_function">hash</a> them, and hash them good.</p>
<blockquote><p>Using raw hash functions to authenticate passwords is as naive as using unsalted hash functions. Don’t. &#8211; <a href="http://chargen.matasano.com/chargen/2007/9/7/enough-with-the-rainbow-tables-what-you-need-to-know-about-s.html">Thomas Ptacek</a></p></blockquote>
<p>So, I was looking for a good implementation of a good hashing algorithm and found one written by <a href="http://derekslager.com/blog/">Derek Slager</a> called <a href="http://derekslager.com/blog/posts/2007/10/bcrypt-dotnet-strong-password-hashing-for-dotnet-and-mono.ashx">BCrypt.net</a>. I really like it. It has a very clean interface and is super easy to use. So to make sure I don&#8217;t lose it (if he would remove it or I would lose the link or something), I post it here. And if it helps someone else to discover it and to ease their day a little, that would be awesome too <img src='http://www.geekality.net/wp-includes/images/blank.gif' alt=':)' class='wp-smiley smiley-1' /> </p>
<p>You use it like this:</p>
<div class="codecolorer-container csharp default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="csharp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #008080; font-style: italic;">// Pass a logRounds parameter to GenerateSalt to explicitly specify the</span><br />
<span style="color: #008080; font-style: italic;">// amount of resources required to check the password. The work factor</span><br />
<span style="color: #008080; font-style: italic;">// increases exponentially, so each increment is twice as much work. If</span><br />
<span style="color: #008080; font-style: italic;">// omitted, a default of 10 is used.</span><br />
<span style="color: #6666cc; font-weight: bold;">string</span> hashed <span style="color: #008000;">=</span> BCrypt<span style="color: #008000;">.</span><span style="color: #0000FF;">HashPassword</span><span style="color: #008000;">&#40;</span>password, BCrypt<span style="color: #008000;">.</span><span style="color: #0000FF;">GenerateSalt</span><span style="color: #008000;">&#40;</span><span style="color: #FF0000;">12</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
<br />
<span style="color: #008080; font-style: italic;">// Check the password.</span><br />
<span style="color: #6666cc; font-weight: bold;">bool</span> matches <span style="color: #008000;">=</span> BCrypt<span style="color: #008000;">.</span><span style="color: #0000FF;">CheckPassword</span><span style="color: #008000;">&#40;</span>candidate, hashed<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span></div></div>
<p>You find the class <a href="http://www.geekality.net/wp-content/uploads/2009/03/BCrypt.cs">here</a>.</p>
<p class="wp-flattr-button"></p>]]></content:encoded>
			<wfw:commentRss>http://www.geekality.net/2009/03/02/a-nice-class-for-hashing/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

