Answers.Body: <p>There is a general config setting for this:</p>
  
  <p><a href="https://craftcms.com/docs/config-settings#blowfishHashCost" rel="nofollow">https://craftcms.com/docs/config-settings#blowfishHashCost</a></p>
  
  <p>Setting this to the minimum value:</p>
  
  <pre><code>'blowfishHashCost' =&gt; 4
  </code></pre>
  
  <p>made the hashing time negligible.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-12-28T00:55:50.207Z
Answers.LastActivityDate: 2015-12-28T00:55:50.207Z
Answers.UserDisplayName: Thomas
Body: <p>I am setting up a system that migrates users from an external source and have determined the most time expensive part is when the UsersService _setPasswordOnUserRecord method hashes the password</p>
  
  <pre><code>$hash = craft()-&gt;security-&gt;hashPassword($user-&gt;newPassword);
  </code></pre>
  
  <p>This is taking about 2 secs where the rest of the operation for saving a user is about .2 sec. There are close to 10k users to it's really adding up! Is there any way to use a faster type of hash or bypass the hashing, or am I out of luck?</p>
  
  <p>example:</p>
  
  <pre><code>    $user = new UserModel;
  
      $user-&gt;firstName    = "First";
      $user-&gt;lastName     = 'last';
      $user-&gt;newPassword  = '123456';
      $user-&gt;email        = 'email@email.com';
      $user-&gt;username     = 'username';
  
  
  
  
      $wasSaved = craft()-&gt;users-&gt;saveUser($user);
  </code></pre>
  
Tags: <plugin-development><php><password>
Title: Is there a way to speed up password hashing?
ThreadText: # Is there a way to speed up password hashing?
  
  (Asked by: username_0 on 2015-12-28)
  
  I am setting up a system that migrates users from an external source and have determined the most time expensive part is when the UsersService \_setPasswordOnUserRecord method hashes the password
  
  ```
  $hash = craft()->security->hashPassword($user->newPassword);
  
  ```
  
  This is taking about 2 secs where the rest of the operation for saving a user is about .2 sec. There are close to 10k users to it's really adding up! Is there any way to use a faster type of hash or bypass the hashing, or am I out of luck?
  
  example:
  
  ```
      $user = new UserModel;
  
      $user->firstName    = "First";
      $user->lastName     = 'last';
      $user->newPassword  = '123456';
      $user->email        = 'email@email.com';
      $user->username     = 'username';
  
      $wasSaved = craft()->users->saveUser($user);
  
  ```
  
  **Tags:** plugin-development, php, password
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2015-12-28. Score: 2
  
  There is a general config setting for this:
  
  <https://craftcms.com/docs/config-settings#blowfishHashCost>
  
  Setting this to the minimum value:
  
  ```
  'blowfishHashCost' => 4
  
  ```
  
  made the hashing time negligible.
  
  
  ---
  
  