title: How can I reuse Authlogic's password encryption functionality in a Rails app?
body: <p>In my Rails app, I periodically require the user to re-enter their password after a certain amount of inactivity--like with sudo on Linux. My app uses Authlogic for authentication and handling password storage and encryption.</p>
  
  <p>I need some method to encrypt the password the user enters using the exact same encryption scheme Authlogic uses to encrypt passwords when it verifies passwords during authentication.  I need to 1) encrypt the password the user enters and 2) do a string comparison between this encryption and the encrypted password stored in the database for the user.</p>
  
  <p>Where should I put the method to perform this encryption? Here are some ideas:</p>
  
  <p>Idea 1 (in a new, custom module)</p>
  
  <pre><code>module PasswordCryption
    include Authlogic::ActsAsAuthentic::Password
  
    encrypt_password(password)
  
    end
  end
  </code></pre>
  
  <p>Idea 2 (in the User model)</p>
  
  <pre><code>class User
    acts_as_authentic &lt;---- makes Authlogic password encryption functionality available
  
    encrypt_password(password)
  
    end
  end
  </code></pre>