<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	>
<channel>
	<title>Comments on: Ruby on Rails Password Hashing Module</title>
	<atom:link href="http://www.zacharyfox.com/blog/ruby-on-rails/password-hashing/feed" rel="self" type="application/rss+xml" />
	<link>http://www.zacharyfox.com/blog/ruby-on-rails/password-hashing</link>
	<description></description>
	<pubDate>Tue, 06 Jan 2009 03:15:51 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.5.1</generator>
		<item>
		<title>By: valley</title>
		<link>http://www.zacharyfox.com/blog/ruby-on-rails/password-hashing#comment-4277</link>
		<dc:creator>valley</dc:creator>
		<pubDate>Mon, 10 Nov 2008 14:10:30 +0000</pubDate>
		<guid isPermaLink="false">http://www.zacharyfox.com/blog/ruby-on-rails/password-hashing#comment-4277</guid>
		<description>In Password.salt  what do i have to enter for salt = .. ?
Whatever i take i get an error 

TypeError (can't convert Fixnum into String):
    /lib/password.rb:33:in `+'
    /lib/password.rb:33:in `salt'
    /lib/password.rb:9:in `update'

in Password.store, and the salt value is never 64 chars long.</description>
		<content:encoded><![CDATA[<p>In Password.salt  what do i have to enter for salt = .. ?<br />
Whatever i take i get an error </p>
<p>TypeError (can&#8217;t convert Fixnum into String):<br />
    /lib/password.rb:33:in `+&#8217;<br />
    /lib/password.rb:33:in `salt&#8217;<br />
    /lib/password.rb:9:in `update&#8217;</p>
<p>in Password.store, and the salt value is never 64 chars long.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Hugo Peixoto</title>
		<link>http://www.zacharyfox.com/blog/ruby-on-rails/password-hashing#comment-2655</link>
		<dc:creator>Hugo Peixoto</dc:creator>
		<pubDate>Sat, 06 Sep 2008 04:58:34 +0000</pubDate>
		<guid isPermaLink="false">http://www.zacharyfox.com/blog/ruby-on-rails/password-hashing#comment-2655</guid>
		<description>@Thomas
Instead of before_create, you could use after_validate_on_create.</description>
		<content:encoded><![CDATA[<p>@Thomas<br />
Instead of before_create, you could use after_validate_on_create.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: fophillips</title>
		<link>http://www.zacharyfox.com/blog/ruby-on-rails/password-hashing#comment-2061</link>
		<dc:creator>fophillips</dc:creator>
		<pubDate>Wed, 30 Jul 2008 00:59:11 +0000</pubDate>
		<guid isPermaLink="false">http://www.zacharyfox.com/blog/ruby-on-rails/password-hashing#comment-2061</guid>
		<description>Is this code released under a specific license? I would like to use it in my project under the AGPL.</description>
		<content:encoded><![CDATA[<p>Is this code released under a specific license? I would like to use it in my project under the AGPL.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Zachary Fox</title>
		<link>http://www.zacharyfox.com/blog/ruby-on-rails/password-hashing#comment-1741</link>
		<dc:creator>Zachary Fox</dc:creator>
		<pubDate>Fri, 11 Jul 2008 14:29:03 +0000</pubDate>
		<guid isPermaLink="false">http://www.zacharyfox.com/blog/ruby-on-rails/password-hashing#comment-1741</guid>
		<description>@Thomas

Good points. These are very simplified examples of code that is in a CMS I wrote. I actually use a before_save method to check the values of password and password_verification fields (which are submitted from a form), along with additional validations to ensure that the password is valid (length, complexity, etc...)

For multiple reasons, I haven't provided complete examples, but enough that you can work with the password.rb lib.

I'm glad you found it useful, and I'll look into the source files to see why the quotes aren't working properly.</description>
		<content:encoded><![CDATA[<p>@Thomas</p>
<p>Good points. These are very simplified examples of code that is in a CMS I wrote. I actually use a before_save method to check the values of password and password_verification fields (which are submitted from a form), along with additional validations to ensure that the password is valid (length, complexity, etc&#8230;)</p>
<p>For multiple reasons, I haven&#8217;t provided complete examples, but enough that you can work with the password.rb lib.</p>
<p>I&#8217;m glad you found it useful, and I&#8217;ll look into the source files to see why the quotes aren&#8217;t working properly.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Thomas</title>
		<link>http://www.zacharyfox.com/blog/ruby-on-rails/password-hashing#comment-1740</link>
		<dc:creator>Thomas</dc:creator>
		<pubDate>Fri, 11 Jul 2008 13:51:27 +0000</pubDate>
		<guid isPermaLink="false">http://www.zacharyfox.com/blog/ruby-on-rails/password-hashing#comment-1740</guid>
		<description>I have to comment myself:

the assignment-method works, but the cost is, you cannot validate the password (e.g. against a minimum length), because validations uses the hashed value of the password. A better approach is:

  protected
  def before_save
    self.password = Password::update(self.password) if self.password_changed?
  end


But even here, you have to validate like this:

  def validate
    if self.password_changed?
      errors.add("password", "at least 10 characters") if self.password.length &#60; 10
    end
  end


since all other validation-methods will use the hashed-version of the password, when you e.g. change some other attribute but not the password.

Best regards
Thomas</description>
		<content:encoded><![CDATA[<p>I have to comment myself:</p>
<p>the assignment-method works, but the cost is, you cannot validate the password (e.g. against a minimum length), because validations uses the hashed value of the password. A better approach is:</p>
<p>  protected<br />
  def before_save<br />
    self.password = Password::update(self.password) if self.password_changed?<br />
  end</p>
<p>But even here, you have to validate like this:</p>
<p>  def validate<br />
    if self.password_changed?<br />
      errors.add(&#8221;password&#8221;, &#8220;at least 10 characters&#8221;) if self.password.length &lt; 10<br />
    end<br />
  end</p>
<p>since all other validation-methods will use the hashed-version of the password, when you e.g. change some other attribute but not the password.</p>
<p>Best regards<br />
Thomas</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Thomas</title>
		<link>http://www.zacharyfox.com/blog/ruby-on-rails/password-hashing#comment-1734</link>
		<dc:creator>Thomas</dc:creator>
		<pubDate>Fri, 11 Jul 2008 11:29:13 +0000</pubDate>
		<guid isPermaLink="false">http://www.zacharyfox.com/blog/ruby-on-rails/password-hashing#comment-1734</guid>
		<description>A few points: Your code gave me a little headache, since it uses dots (.) where ruby expects quotes (' or "), but this was solved very fast.

Second, in User.rb, the password will only be hashed, when the user is created. If you change the password, it just stores the plain password. 

So instead of using before_create you could just overwrite the assignment method:

  def password=(pass)

    write_attribute(:password, password = Password::update(pass))

  end

Now the password will always be hashed.

Best Regards
Thomas

P.S.: be sure to remove before_create, otherwise your password will be hashed twice and you cannot login.</description>
		<content:encoded><![CDATA[<p>A few points: Your code gave me a little headache, since it uses dots (.) where ruby expects quotes (&#8217; or &#8220;), but this was solved very fast.</p>
<p>Second, in User.rb, the password will only be hashed, when the user is created. If you change the password, it just stores the plain password. </p>
<p>So instead of using before_create you could just overwrite the assignment method:</p>
<p>  def password=(pass)</p>
<p>    write_attribute(:password, password = Password::update(pass))</p>
<p>  end</p>
<p>Now the password will always be hashed.</p>
<p>Best Regards<br />
Thomas</p>
<p>P.S.: be sure to remove before_create, otherwise your password will be hashed twice and you cannot login.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Gerrad Fase</title>
		<link>http://www.zacharyfox.com/blog/ruby-on-rails/password-hashing#comment-327</link>
		<dc:creator>Gerrad Fase</dc:creator>
		<pubDate>Thu, 28 Feb 2008 04:37:18 +0000</pubDate>
		<guid isPermaLink="false">http://www.zacharyfox.com/blog/ruby-on-rails/password-hashing#comment-327</guid>
		<description>Got it! Thanks a ton - now to put it to work.</description>
		<content:encoded><![CDATA[<p>Got it! Thanks a ton - now to put it to work.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Zachary Fox</title>
		<link>http://www.zacharyfox.com/blog/ruby-on-rails/password-hashing#comment-324</link>
		<dc:creator>Zachary Fox</dc:creator>
		<pubDate>Tue, 26 Feb 2008 23:12:59 +0000</pubDate>
		<guid isPermaLink="false">http://www.zacharyfox.com/blog/ruby-on-rails/password-hashing#comment-324</guid>
		<description>I've updated this page so that you can download the password.rb file. Just look at the bottom of the source code for a link to download it.</description>
		<content:encoded><![CDATA[<p>I&#8217;ve updated this page so that you can download the password.rb file. Just look at the bottom of the source code for a link to download it.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Gerrad Fase</title>
		<link>http://www.zacharyfox.com/blog/ruby-on-rails/password-hashing#comment-322</link>
		<dc:creator>Gerrad Fase</dc:creator>
		<pubDate>Tue, 26 Feb 2008 14:33:12 +0000</pubDate>
		<guid isPermaLink="false">http://www.zacharyfox.com/blog/ruby-on-rails/password-hashing#comment-322</guid>
		<description>Where can I download this library - is it an available Gem on RubyForge?</description>
		<content:encoded><![CDATA[<p>Where can I download this library - is it an available Gem on RubyForge?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: de tomKronieken &#187; Blog Archive &#187; links for 2008-01-23</title>
		<link>http://www.zacharyfox.com/blog/ruby-on-rails/password-hashing#comment-194</link>
		<dc:creator>de tomKronieken &#187; Blog Archive &#187; links for 2008-01-23</dc:creator>
		<pubDate>Wed, 23 Jan 2008 19:24:13 +0000</pubDate>
		<guid isPermaLink="false">http://www.zacharyfox.com/blog/ruby-on-rails/password-hashing#comment-194</guid>
		<description>[...] Ruby on Rails Password Hashing Module Shared with shareomatic.com [...]</description>
		<content:encoded><![CDATA[<p>[...] Ruby on Rails Password Hashing Module Shared with shareomatic.com [...]</p>
]]></content:encoded>
	</item>
</channel>
</rss>
