======================
generate_password_hash
======================

.. py:method:: generate_password_hash(self, password, method='pbkdf2:sha256', salt_length=8)

**domain**: server

**language**: python

**class** :doc:`Task class </refs/server/task_api>`

Description
===========

This method hash a password with the given method and salt with a string of 
the given length. The format of the string returned includes the method that was 
used so that 
:doc:`check_password_hash <m_check_password_hash>`
can check the hash.

The method is wrapper over Werkzeug **generate_password_hash** function: 
https://werkzeug.palletsprojects.com/en/0.15.x/utils/

Example
=======


.. code-block:: py

  def on_apply(item, delta, params, connection):
      for d in delta:
          if d.password.value:
              d.edit();
              d.password_hash.value = delta.task.generate_password_hash(d.password.value)
              d.password.value = None
              d.post();

See also
========

:doc:`check_password_hash <m_check_password_hash>`