Salted hash login generator

Hi - if you can't get this to work you could try building your own?

Class User

before_create :create_salt

  def create_salt
    unless self.salt
      self.salt = random_salt
    end
  end

  def random_salt
    nums = ("0".."9").to_a
    random = ""
    1.upto(5) { |i| newrand << numbers[rand(numbers.size - 1)]}
    return random
  end

  def hash_password
    update_attribute :password, Digest::MD5.hexdigest("#{self.salt}#
{self.password.downcase}")
  end

  def password_matches? password_to_match
     password == Digest::MD5.hexdigest("#{self.salt}#
{password_to_match.downcase}")
  end
end

Just call hash_password after you save the user or update the password
and call password_matches? to check that the password provided is the
correct one.

Hope that helps?