summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEli Collins <elic@assurancetechnologies.com>2016-11-28 12:08:37 -0500
committerEli Collins <elic@assurancetechnologies.com>2016-11-28 12:08:37 -0500
commit692a18ce4cddeaeaaec1cfb8bd8bbec263027a8f (patch)
tree44f298775aa78c4c1e06a538efb39db373f2d3d6
parent131bb9c477ce273222f8946130fba638407296b5 (diff)
parent210537f1210e13f17efa734ea080f1d70d605603 (diff)
downloadpasslib-692a18ce4cddeaeaaec1cfb8bd8bbec263027a8f.tar.gz
Merge with stable
-rw-r--r--docs/conf.py2
-rw-r--r--docs/history/1.5.rst6
-rw-r--r--docs/history/1.6.rst6
-rw-r--r--docs/history/1.7.rst18
-rw-r--r--docs/history/ancient.rst6
-rw-r--r--docs/history/index.rst35
-rw-r--r--docs/index.rst11
-rw-r--r--docs/install.rst21
-rw-r--r--docs/lib/passlib.apps.rst8
-rw-r--r--docs/lib/passlib.context.rst8
-rw-r--r--docs/lib/passlib.hash.argon2.rst2
-rw-r--r--docs/lib/passlib.hash.bcrypt.rst2
-rw-r--r--docs/lib/passlib.hash.bcrypt_sha256.rst2
-rw-r--r--docs/lib/passlib.hash.bsdi_crypt.rst2
-rw-r--r--docs/lib/passlib.hash.cisco_pix.rst4
-rw-r--r--docs/lib/passlib.hash.des_crypt.rst2
-rw-r--r--docs/lib/passlib.hash.django_std.rst4
-rw-r--r--docs/lib/passlib.hash.fshp.rst2
-rw-r--r--docs/lib/passlib.hash.hex_digests.rst2
-rw-r--r--docs/lib/passlib.hash.ldap_crypt.rst2
-rw-r--r--docs/lib/passlib.hash.ldap_std.rst2
-rw-r--r--docs/lib/passlib.hash.lmhash.rst2
-rw-r--r--docs/lib/passlib.hash.md5_crypt.rst4
-rw-r--r--docs/lib/passlib.hash.msdcc.rst2
-rw-r--r--docs/lib/passlib.hash.msdcc2.rst2
-rw-r--r--docs/lib/passlib.hash.mssql2000.rst2
-rw-r--r--docs/lib/passlib.hash.mssql2005.rst2
-rw-r--r--docs/lib/passlib.hash.mysql323.rst2
-rw-r--r--docs/lib/passlib.hash.nthash.rst2
-rw-r--r--docs/lib/passlib.hash.oracle10.rst2
-rw-r--r--docs/lib/passlib.hash.oracle11.rst2
-rw-r--r--docs/lib/passlib.hash.pbkdf2_digest.rst2
-rw-r--r--docs/lib/passlib.hash.postgres_md5.rst2
-rw-r--r--docs/lib/passlib.hash.rst14
-rw-r--r--docs/lib/passlib.hash.scram.rst2
-rw-r--r--docs/lib/passlib.hash.scrypt.rst2
-rw-r--r--docs/lib/passlib.hash.sha256_crypt.rst2
-rw-r--r--docs/lib/passlib.hash.unix_disabled.rst2
-rw-r--r--docs/lib/passlib.hosts.rst8
-rw-r--r--docs/lib/passlib.ifc.rst2
-rw-r--r--docs/narr/context-tutorial.rst6
-rw-r--r--docs/narr/hash-tutorial.rst95
-rw-r--r--docs/narr/overview.rst10
-rw-r--r--docs/narr/quickstart.rst10
-rw-r--r--passlib/apache.py4
-rw-r--r--passlib/exc.py2
-rw-r--r--passlib/handlers/md5_crypt.py2
-rw-r--r--passlib/handlers/misc.py4
-rw-r--r--passlib/handlers/sha2_crypt.py2
-rw-r--r--passlib/tests/test_context.py33
-rw-r--r--passlib/tests/test_ext_django.py5
-rw-r--r--passlib/tests/test_handlers_pbkdf2.py10
-rw-r--r--passlib/tests/test_utils_handlers.py6
-rw-r--r--passlib/tests/utils.py20
-rw-r--r--passlib/utils/__init__.py9
-rw-r--r--passlib/utils/handlers.py11
56 files changed, 253 insertions, 181 deletions
diff --git a/docs/conf.py b/docs/conf.py
index b45d17a..7adac8b 100644
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -109,6 +109,8 @@ from passlib import __version__ as release
version = csp.get_version(release)
if ".dev" in release:
tags.add("devcopy")
+if 'for-pypi' in options:
+ tags.add("pypi")
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
diff --git a/docs/history/1.5.rst b/docs/history/1.5.rst
index 575e81b..9d4135c 100644
--- a/docs/history/1.5.rst
+++ b/docs/history/1.5.rst
@@ -1,6 +1,6 @@
-==========
-1.5 Series
-==========
+===========
+Passlib 1.5
+===========
.. _bcrypt-padding-issue:
diff --git a/docs/history/1.6.rst b/docs/history/1.6.rst
index 6b88c4b..1406b5f 100644
--- a/docs/history/1.6.rst
+++ b/docs/history/1.6.rst
@@ -1,6 +1,6 @@
-==========
-1.6 Series
-==========
+===========
+Passlib 1.6
+===========
**1.6.5** (2015-08-04)
======================
diff --git a/docs/history/1.7.rst b/docs/history/1.7.rst
index ba9b926..9f8f735 100644
--- a/docs/history/1.7.rst
+++ b/docs/history/1.7.rst
@@ -1,13 +1,17 @@
-.. _whats-new:
+===========
+Passlib 1.7
+===========
+
+**1.7.1** (NOT YET RELEASED)
+============================
-==========
-1.7 Series
-==========
+.. py:currentmodule:: passlib.ifc
-.. seealso::
+* bugfix: :meth:`PasswordHash.hash` will now warn if passed any settings
+ keywords. This usage was deprecated in 1.7.0, but warning wasn't properly enabled.
+ See :ref:`hash-configuring` for the preferred way to pass settings.
- The `Roadmap <https://bitbucket.org/ecollins/passlib/wiki/Roadmap>`_
- for a list of future changes that may impact applications.
+.. _whats-new:
.. rst-class:: emphasize-children toc-always-open
diff --git a/docs/history/ancient.rst b/docs/history/ancient.rst
index 797f584..f8a34ed 100644
--- a/docs/history/ancient.rst
+++ b/docs/history/ancient.rst
@@ -1,6 +1,6 @@
-=============
-1.4 & Earlier
-=============
+=====================
+Passlib 1.4 & Earlier
+=====================
**1.4** (2011-05-04)
====================
diff --git a/docs/history/index.rst b/docs/history/index.rst
index c4a6689..219b713 100644
--- a/docs/history/index.rst
+++ b/docs/history/index.rst
@@ -4,19 +4,36 @@
Release History
===============
-.. centered:: This is the documentation for the :ref:`1.7.0 Release <whats-new>` of Passlib.
-
-.. rst-class:: float-right
+.. rst-class:: float-center without-title
.. seealso::
- The `Roadmap <https://bitbucket.org/ecollins/passlib/wiki/Roadmap>`_
- for a list of future changes that may impact applications.
+ **For the latest release:** see :ref:`What's New <whats-new>` in Passlib 1.7
+
+.. toctree::
+ :maxdepth: 2
+
+ 1.7 Series <1.7>
+
+.. toctree::
+ :maxdepth: 2
+
+ 1.6 Series <1.6>
.. toctree::
:maxdepth: 2
- 1.7
- 1.6
- 1.5
- ancient
+ 1.5 Series <1.5>
+
+.. toctree::
+ :maxdepth: 2
+
+ 1.4 & Earlier <ancient>
+
+.. rst-class:: float-center without-title
+
+.. seealso::
+
+ See the `Project Roadmap <https://bitbucket.org/ecollins/passlib/wiki/Roadmap>`_
+ for a list of future changes that may impact applications.
+
diff --git a/docs/index.rst b/docs/index.rst
index d21f9ee..8409ef9 100644
--- a/docs/index.rst
+++ b/docs/index.rst
@@ -2,7 +2,8 @@
:align: center
:class: show-for-small
-.. rst-class:: float-right without-title
+
+.. rst-class:: float-right
.. seealso:: :ref:`What's new in Passlib 1.7 <whats-new>`
@@ -18,6 +19,14 @@ Passlib |release| documentation
For documentation of the latest stable version,
see `<https://passlib.readthedocs.io>`_.
+.. only:: pypi
+
+ .. warning::
+
+ The official Passlib documentation have moved to `<https://passlib.readthedocs.io>`_.
+ Documentation at this location is still being maintained,
+ but will be updated much less frequently.
+
Welcome
=======
Passlib is a password hashing library for Python 2 & 3, which provides
diff --git a/docs/install.rst b/docs/install.rst
index 6ee3d7f..2212383 100644
--- a/docs/install.rst
+++ b/docs/install.rst
@@ -104,21 +104,30 @@ Testing
Passlib contains a comprehensive set of unittests (about 38% of the total code),
which provide nearly complete coverage, and verification of the hash
algorithms using multiple external sources (if detected at runtime).
+
All unit tests are contained within the :mod:`passlib.tests` subpackage,
and are designed to be run using the
`Nose <http://somethingaboutorange.com/mrl/projects/nose>`_ unit testing library
(as well as the ``unittest2`` library under Python 2.6).
-Once Passlib and Nose have been installed, the main suite of tests may be run from the source directory::
+Once Passlib and Nose have been installed, the main suite of tests may be run using::
+
+ nosetests --tests passlib.tests
+
+By default, this runs the main battery of tests, but omits some additional ones
+(such as internal cross-checks, and mock-testing of features not provided natively by the host OS).
+To run these tests as well, set the following environmental variable::
- nosetests --tests passlib/tests
+ PASSLIB_TEST_MODE="full" nosetests --tests passlib.tests
-To run the full test suite, which includes internal cross-checks and mock-testing
-of features not provided natively by the host OS::
+To run a quick check to confirm just basic functionality, with a pared-down set of tests::
- PASSLIB_TEST_MODE="full" nosetests --tests passlib/tests
+ PASSLIB_TEST_MODE="quick" nosetests --tests passlib.tests
Tests may also be run via ``setup.py test`` or the included ``tox.ini`` file.
+The ``tox.ini`` file is used to test passlib before each release,
+and contains a number different environment setups.
+These tests require `tox <https://pypi.python.org/pypi/tox>`_ 2.5 or later.
.. rst-class:: html-toggle
@@ -129,7 +138,7 @@ online at `<https://passlib.readthedocs.io>`_.
If you wish to generate your own copy of the documentation,
you will need to:
-1. Install `Sphinx <http://sphinx.pocoo.org/>`_ (1.3 or newer)
+1. Install `Sphinx <http://sphinx.pocoo.org/>`_ (1.4 or newer)
2. Install the `Cloud Sphinx Theme <http://packages.python.org/cloud_sptheme>`_ (1.8 or newer).
3. Download the Passlib source
4. From the Passlib source directory, run :samp:`python setup.py build_sphinx`.
diff --git a/docs/lib/passlib.apps.rst b/docs/lib/passlib.apps.rst
index e89b804..7e5559f 100644
--- a/docs/lib/passlib.apps.rst
+++ b/docs/lib/passlib.apps.rst
@@ -3,7 +3,7 @@
==================================================================
.. module:: passlib.apps
- :synopsis: encrypting & verifying passwords used in sql servers and other applications
+ :synopsis: hashing & verifying passwords used in sql servers and other applications
.. _predefined-context-example:
@@ -23,7 +23,7 @@ Each of the objects in this module can be imported directly::
>>> # a helper to let new applications *quickly* add password hashing.
>>> from passlib.apps import custom_app_context
-Encrypting a password is simple (and salt generation is handled automatically)::
+Hashing a password is simple (and salt generation is handled automatically)::
>>> hash = custom_app_context.hash("toomanysecrets")
>>> hash
@@ -185,11 +185,11 @@ PostgreSQL
This object should recognize password hashes stores in PostgreSQL's ``pg_shadow`` table;
which are all assumed to follow the :class:`~passlib.hash.postgres_md5` format.
- Note that the username must be provided whenever encrypting or verifying a postgres hash::
+ Note that the username must be provided whenever hashing or verifying a postgres hash::
>>> from passlib.apps import postgres_context
- >>> # encrypting a password...
+ >>> # hashing a password...
>>> postgres_context.hash("somepass", user="dbadmin")
'md578ed0f0ab2be0386645c1b74282917e7'
diff --git a/docs/lib/passlib.context.rst b/docs/lib/passlib.context.rst
index 2c95a74..b2f7248 100644
--- a/docs/lib/passlib.context.rst
+++ b/docs/lib/passlib.context.rst
@@ -23,7 +23,7 @@ The CryptContext Class
======================
.. class:: CryptContext(schemes=None, \*\*kwds)
- Helper for encrypting passwords using different algorithms.
+ Helper for hashing passwords using different algorithms.
At its base, this is a proxy object that makes it easy to use
multiple :class:`~passlib.ifc.PasswordHash` objects at the same time.
@@ -104,7 +104,7 @@ Options which directly affect the behavior of the CryptContext instance:
Specifies the name of the default scheme.
This option controls which of the configured
- schemes will be used as the default when encrypting
+ schemes will be used as the default when creating
new hashes. This parameter is optional; if omitted,
the first non-deprecated algorithm in ``schemes`` will be used.
You can use the :meth:`~CryptContext.default_scheme` method
@@ -400,7 +400,7 @@ For example, a CryptContext could be set up as follows::
... sha256_crypt__default_rounds=77000,
... staff__sha256_crypt__default_rounds=88000)
- >>> # In this case, calling encrypt with ``category=None`` would result
+ >>> # In this case, calling hash() with ``category=None`` would result
>>> # in a hash that used 77000 sha256-crypt rounds:
>>> myctx.hash("password", category=None)
'$5$rounds=77000$sj3XI0AbKlEydAKt$BhFvyh4.IoxaUeNlW6rvQ.O0w8BtgLQMYorkCOMzf84'
@@ -442,7 +442,7 @@ style methods provided by all the :class:`~passlib.ifc.PasswordHash` objects:
Hash Migration
--------------
-Applications which want to detect and re-encrypt deprecated
+Applications which want to detect and regenerate deprecated
hashes will want to use one of the following methods:
.. automethod:: CryptContext.verify_and_update
diff --git a/docs/lib/passlib.hash.argon2.rst b/docs/lib/passlib.hash.argon2.rst
index 0eb1ad6..fcc9508 100644
--- a/docs/lib/passlib.hash.argon2.rst
+++ b/docs/lib/passlib.hash.argon2.rst
@@ -17,7 +17,7 @@ for new applications. This class can be used directly as follows::
>>> from passlib.hash import argon2
- >>> # generate new salt, encrypt password
+ >>> # generate new salt, hash password
>>> h = argon2.hash("password")
>>> h
'$argon2i$v=19$m=512,t=2,p=2$aI2R0hpDyLm3ltLa+1/rvQ$LqPKjd6n8yniKtAithoR7A'
diff --git a/docs/lib/passlib.hash.bcrypt.rst b/docs/lib/passlib.hash.bcrypt.rst
index 946c5ff..4683690 100644
--- a/docs/lib/passlib.hash.bcrypt.rst
+++ b/docs/lib/passlib.hash.bcrypt.rst
@@ -13,7 +13,7 @@ for new applications. This class can be used directly as follows::
>>> from passlib.hash import bcrypt
- >>> # generate new salt, encrypt password
+ >>> # generate new salt, hash password
>>> h = bcrypt.hash("password")
>>> h
'$2a$12$NT0I31Sa7ihGEWpka9ASYrEFkhuTNeBQ2xfZskIiiJeyFXhRgS.Sy'
diff --git a/docs/lib/passlib.hash.bcrypt_sha256.rst b/docs/lib/passlib.hash.bcrypt_sha256.rst
index a7470c0..c9d2870 100644
--- a/docs/lib/passlib.hash.bcrypt_sha256.rst
+++ b/docs/lib/passlib.hash.bcrypt_sha256.rst
@@ -15,7 +15,7 @@ This class can be used directly as follows::
>>> from passlib.hash import bcrypt_sha256
- >>> # generate new salt, encrypt password
+ >>> # generate new salt, hash password
>>> h = bcrypt_sha256.hash("password")
>>> h
'$bcrypt-sha256$2a,12$LrmaIX5x4TRtAwEfwJZa1.$2ehnw6LvuIUTM0iz4iz9hTxv21B6KFO'
diff --git a/docs/lib/passlib.hash.bsdi_crypt.rst b/docs/lib/passlib.hash.bsdi_crypt.rst
index cb82797..dde7dee 100644
--- a/docs/lib/passlib.hash.bsdi_crypt.rst
+++ b/docs/lib/passlib.hash.bsdi_crypt.rst
@@ -14,7 +14,7 @@ It class can be used directly as follows::
>>> from passlib.hash import bsdi_crypt
- >>> # generate new salt, encrypt password
+ >>> # generate new salt, hash password
>>> hash = bsdi_crypt.hash("password")
>>> hash
'_7C/.Bf/4gZk10RYRs4Y'
diff --git a/docs/lib/passlib.hash.cisco_pix.rst b/docs/lib/passlib.hash.cisco_pix.rst
index d879748..5b00b83 100644
--- a/docs/lib/passlib.hash.cisco_pix.rst
+++ b/docs/lib/passlib.hash.cisco_pix.rst
@@ -30,7 +30,7 @@ newer systems. They can be used directly as follows::
>>> from passlib.hash import cisco_pix as pix
- >>> # encrypt password using specified username
+ >>> # hash password using specified username
>>> hash = pix.hash("password", user="user")
>>> hash
'A5XOy94YKDPXCo7U'
@@ -45,7 +45,7 @@ newer systems. They can be used directly as follows::
>>> pm.verify("letmein", hash, user="user")
False
- >>> # encrypt password without associate user account
+ >>> # hash password without associated user account
>>> hash2 = pix.hash("password")
>>> hash2
'NuLKvvWGg.x9HEKO'
diff --git a/docs/lib/passlib.hash.des_crypt.rst b/docs/lib/passlib.hash.des_crypt.rst
index 7aa6528..c282d5e 100644
--- a/docs/lib/passlib.hash.des_crypt.rst
+++ b/docs/lib/passlib.hash.des_crypt.rst
@@ -13,7 +13,7 @@ It can used directly as follows::
>>> from passlib.hash import des_crypt
- >>> # generate new salt, encrypt password
+ >>> # generate new salt, hash password
>>> hash = des_crypt.hash("password")
'JQMuyS6H.AGMo'
diff --git a/docs/lib/passlib.hash.django_std.rst b/docs/lib/passlib.hash.django_std.rst
index 02116c6..5135f4f 100644
--- a/docs/lib/passlib.hash.django_std.rst
+++ b/docs/lib/passlib.hash.django_std.rst
@@ -96,7 +96,7 @@ These classes can be used directly as follows::
>>> from passlib.hash import django_pbkdf2_sha256 as handler
- >>> # encrypt password
+ >>> # hash password
>>> h = handler.hash("password")
>>> h
'pbkdf2_sha256$10000$s1w0UXDd00XB$+4ORmyvVWAQvoAEWlDgN34vlaJx1ZTZpa1pCSRey2Yk='
@@ -176,7 +176,7 @@ These classes can be used directly as follows::
>>> from passlib.hash import django_salted_sha1 as handler
- >>> # encrypt password
+ >>> # hash password
>>> h = handler.hash("password")
>>> h
'sha1$c6218$161d1ac8ab38979c5a31cbaba4a67378e7e60845'
diff --git a/docs/lib/passlib.hash.fshp.rst b/docs/lib/passlib.hash.fshp.rst
index 6ffefd0..ef959d3 100644
--- a/docs/lib/passlib.hash.fshp.rst
+++ b/docs/lib/passlib.hash.fshp.rst
@@ -23,7 +23,7 @@ It can be used directly as follows::
>>> from passlib.hash import fshp
- >>> # generate new salt, encrypt password
+ >>> # generate new salt, hash password
>>> hash = fshp.hash("password")
>>> hash
'{FSHP1|16|16384}PtoqcGUetmVEy/uR8715TNqKa8+teMF9qZO1lA9lJNUm1EQBLPZ+qPRLeEPHqy6C'
diff --git a/docs/lib/passlib.hash.hex_digests.rst b/docs/lib/passlib.hash.hex_digests.rst
index 8e66b87..ce30faf 100644
--- a/docs/lib/passlib.hash.hex_digests.rst
+++ b/docs/lib/passlib.hash.hex_digests.rst
@@ -22,7 +22,7 @@ and can be used directly as follows::
>>> from passlib.hash import hex_sha1 as hex_sha1
- >>> # encrypt password
+ >>> # hash password
>>> h = hex_sha1.hash("password")
>>> h
'5baa61e4c9b93f3f0682250b6cf8331b7ee68fd8'
diff --git a/docs/lib/passlib.hash.ldap_crypt.rst b/docs/lib/passlib.hash.ldap_crypt.rst
index ede7c5f..7cd2df8 100644
--- a/docs/lib/passlib.hash.ldap_crypt.rst
+++ b/docs/lib/passlib.hash.ldap_crypt.rst
@@ -20,7 +20,7 @@ elsewhere in Passlib, and can be used directly as follows::
>>> from passlib.hash import ldap_md5_crypt
- >>> # encrypt password
+ >>> # hash password
>>> hash = ldap_md5_crypt.hash("password")
>>> hash
'{CRYPT}$1$gwvn5BO0$3dyk8j.UTcsNUPrLMsU6/0'
diff --git a/docs/lib/passlib.hash.ldap_std.rst b/docs/lib/passlib.hash.ldap_std.rst
index 12c2abd..d3788c1 100644
--- a/docs/lib/passlib.hash.ldap_std.rst
+++ b/docs/lib/passlib.hash.ldap_std.rst
@@ -14,7 +14,7 @@ and are can be used directly as follows::
>>> from passlib.hash import ldap_salted_md5 as lsm
- >>> # encrypt password
+ >>> # hash password
>>> hash = lsm.hash("password")
>>> hash
'{SMD5}OqsUXNHIhHbznxrqHoIM+ZT8DmE='
diff --git a/docs/lib/passlib.hash.lmhash.rst b/docs/lib/passlib.hash.lmhash.rst
index 26a4164..65acdf8 100644
--- a/docs/lib/passlib.hash.lmhash.rst
+++ b/docs/lib/passlib.hash.lmhash.rst
@@ -20,7 +20,7 @@ This class can be used directly as follows::
>>> from passlib.hash import lmhash
- >>> # encrypt password
+ >>> # hash password
>>> h = lmhash.hash("password")
>>> h
'e52cac67419a9a224a3b108f3fa6cb6d'
diff --git a/docs/lib/passlib.hash.md5_crypt.rst b/docs/lib/passlib.hash.md5_crypt.rst
index 844b6b6..f3c9279 100644
--- a/docs/lib/passlib.hash.md5_crypt.rst
+++ b/docs/lib/passlib.hash.md5_crypt.rst
@@ -25,7 +25,7 @@ The :class:`!md5_crypt` class can be can be used directly as follows::
>>> from passlib.hash import md5_crypt
- >>> # generate new salt, encrypt password
+ >>> # generate new salt, hash password
>>> h = md5_crypt.hash("password")
>>> h
'$1$3azHgidD$SrJPt7B.9rekpmwJwtON31'
@@ -36,7 +36,7 @@ The :class:`!md5_crypt` class can be can be used directly as follows::
>>> md5_crypt.verify("secret", h)
False
- >>> # encrypt password using cisco-compatible 4-char salt
+ >>> # hash password using cisco-compatible 4-char salt
>>> md5_crypt.using(salt_size=4).hash("password")
'$1$wu98$9UuD3hvrwehnqyF1D548N0'
diff --git a/docs/lib/passlib.hash.msdcc.rst b/docs/lib/passlib.hash.msdcc.rst
index acfd87f..5b39caa 100644
--- a/docs/lib/passlib.hash.msdcc.rst
+++ b/docs/lib/passlib.hash.msdcc.rst
@@ -24,7 +24,7 @@ This class can be used directly as follows::
>>> from passlib.hash import msdcc
- >>> # encrypt password using specified username
+ >>> # hash password using specified username
>>> hash = msdcc.hash("password", user="Administrator")
>>> hash
'25fd08fa89795ed54207e6e8442a6ca0'
diff --git a/docs/lib/passlib.hash.msdcc2.rst b/docs/lib/passlib.hash.msdcc2.rst
index 203d957..4510c10 100644
--- a/docs/lib/passlib.hash.msdcc2.rst
+++ b/docs/lib/passlib.hash.msdcc2.rst
@@ -21,7 +21,7 @@ This class can be used directly as follows::
>>> from passlib.hash import msdcc2
- >>> # encrypt password using specified username
+ >>> # hash password using specified username
>>> hash = msdcc2.hash("password", user="Administrator")
>>> hash
'4c253e4b65c007a8cd683ea57bc43c76'
diff --git a/docs/lib/passlib.hash.mssql2000.rst b/docs/lib/passlib.hash.mssql2000.rst
index 481008c..6da9c8f 100644
--- a/docs/lib/passlib.hash.mssql2000.rst
+++ b/docs/lib/passlib.hash.mssql2000.rst
@@ -16,7 +16,7 @@ This class can be used directly as follows::
>>> from passlib.hash import mssql2000 as m20
- >>> # encrypt password
+ >>> # hash password
>>> h = m20.hash("password")
>>> h
'0x0100200420C4988140FD3920894C3EDC188E94F428D57DAD5905F6CC1CBAF950CAD4C63F272B2C91E4DEEB5E6444'
diff --git a/docs/lib/passlib.hash.mssql2005.rst b/docs/lib/passlib.hash.mssql2005.rst
index bb6b0ec..5d7a7a7 100644
--- a/docs/lib/passlib.hash.mssql2005.rst
+++ b/docs/lib/passlib.hash.mssql2005.rst
@@ -15,7 +15,7 @@ This class can be used directly as follows::
>>> from passlib.hash import mssql2005 as m25
- >>> # encrypt password
+ >>> # hash password
>>> h = m25.hash("password")
>>> h
'0x01006ACDF9FF5D2E211B392EEF1175EFFE13B3A368CE2F94038B'
diff --git a/docs/lib/passlib.hash.mysql323.rst b/docs/lib/passlib.hash.mysql323.rst
index eab3e3e..a8e8bfd 100644
--- a/docs/lib/passlib.hash.mysql323.rst
+++ b/docs/lib/passlib.hash.mysql323.rst
@@ -19,7 +19,7 @@ That aside, this class can be used as follows::
>>> from passlib.hash import mysql323
- >>> # encrypt password
+ >>> # hash password
>>> mysql323.hash("password")
'5d2e19393cc5ef67'
diff --git a/docs/lib/passlib.hash.nthash.rst b/docs/lib/passlib.hash.nthash.rst
index 92c934e..237372a 100644
--- a/docs/lib/passlib.hash.nthash.rst
+++ b/docs/lib/passlib.hash.nthash.rst
@@ -17,7 +17,7 @@ This class can be used directly as follows::
>>> from passlib.hash import nthash
- >>> # encrypt password
+ >>> # hash password
>>> h = nthash.hash("password")
>>> h
'8846f7eaee8fb117ad06bdd830b7586c'
diff --git a/docs/lib/passlib.hash.oracle10.rst b/docs/lib/passlib.hash.oracle10.rst
index 3d697c2..de874d4 100644
--- a/docs/lib/passlib.hash.oracle10.rst
+++ b/docs/lib/passlib.hash.oracle10.rst
@@ -13,7 +13,7 @@ a username for all encrypt/verify operations)::
>>> from passlib.hash import oracle10 as oracle10
- >>> # encrypt password using specified username
+ >>> # hash password using specified username
>>> hash = oracle10.hash("password", user="username")
>>> hash
'872805F3F4C83365'
diff --git a/docs/lib/passlib.hash.oracle11.rst b/docs/lib/passlib.hash.oracle11.rst
index 0953ead..bf2ad1d 100644
--- a/docs/lib/passlib.hash.oracle11.rst
+++ b/docs/lib/passlib.hash.oracle11.rst
@@ -10,7 +10,7 @@ This class can be can be used directly as follows::
>>> from passlib.hash import oracle11 as oracle11
- >>> # generate new salt, encrypt password
+ >>> # generate new salt, hash password
>>> hash = oracle11.hash("password")
>>> hash
'S:4143053633E59B4992A8EA17D2FF542C9EDEB335C886EED9C80450C1B4E6'
diff --git a/docs/lib/passlib.hash.pbkdf2_digest.rst b/docs/lib/passlib.hash.pbkdf2_digest.rst
index 10e68ba..a918167 100644
--- a/docs/lib/passlib.hash.pbkdf2_digest.rst
+++ b/docs/lib/passlib.hash.pbkdf2_digest.rst
@@ -26,7 +26,7 @@ All of these classes can be used directly as follows::
>>> from passlib.hash import pbkdf2_sha256
- >>> # generate new salt, encrypt password
+ >>> # generate new salt, hash password
>>> hash = pbkdf2_sha256.hash("password")
>>> hash
'$pbkdf2-sha256$6400$0ZrzXitFSGltTQnBWOsdAw$Y11AchqV4b0sUisdZd0Xr97KWoymNE0LNNrnEgY4H9M'
diff --git a/docs/lib/passlib.hash.postgres_md5.rst b/docs/lib/passlib.hash.postgres_md5.rst
index 4627eb7..7a88bb8 100644
--- a/docs/lib/passlib.hash.postgres_md5.rst
+++ b/docs/lib/passlib.hash.postgres_md5.rst
@@ -17,7 +17,7 @@ That aside, this class can be used directly as follows::
>>> from passlib.hash import postgres_md5
- >>> # encrypt password using specified username
+ >>> # hash password using specified username
>>> hash = postgres_md5.hash("password", user="username")
>>> hash
'md55a231fcdb710d73268c4f44283487ba2'
diff --git a/docs/lib/passlib.hash.rst b/docs/lib/passlib.hash.rst
index f5a728c..3211066 100644
--- a/docs/lib/passlib.hash.rst
+++ b/docs/lib/passlib.hash.rst
@@ -20,11 +20,9 @@ including its format, underlying algorithm, and known security issues.
**Many of the hash algorithms listed below are *NOT* secure.**
Passlib supports a wide array of hash algorithms, primarily to
- support dealing with legacy data and systems.
-
- If you're looking to choose a hash algorithm for a new application,
- see the :doc:`Quickstart Guide </narr/quickstart>` instead of picking
- one from this list.
+ support legacy data and systems.
+ If you want to choose a secure algorithm for a new application,
+ see the :doc:`Quickstart Guide </narr/quickstart>`.
.. rst-class:: float-center
@@ -49,7 +47,7 @@ by other applications and password hash schemes.
Active Unix Hashes
------------------
-All these schemes are actively in use by various Unix flavors to store user passwords.
+All the following schemes are actively in use by various Unix flavors to store user passwords
They all follow the modular crypt format.
.. toctree::
@@ -73,8 +71,8 @@ found in many Linux & BSD password files:
Deprecated Unix Hashes
----------------------
The following schemes are supported by various Unix systems
-use the modular crypt format, and are noticably stronger than the previous group.
-However, they have all since been deprecated in favor of stronger algorithms:
+using the modular crypt format, but are no longer considered secure,
+and have been deprecated in favor of the `Active Unix Hashes`_ (above).
* :class:`passlib.hash.bsd_nthash` - FreeBSD's MCF-compatible encoding of :doc:`nthash <passlib.hash.nthash>` digests
diff --git a/docs/lib/passlib.hash.scram.rst b/docs/lib/passlib.hash.scram.rst
index a1f63b6..48e2ed0 100644
--- a/docs/lib/passlib.hash.scram.rst
+++ b/docs/lib/passlib.hash.scram.rst
@@ -36,7 +36,7 @@ This class can be used like any other Passlib hash, as follows::
>>> from passlib.hash import scram
- >>> # generate new salt, encrypt password against default list of algorithms
+ >>> # generate new salt, hash password against default list of algorithms
>>> hash = scram.hash("password")
>>> hash
'$scram$6400$.Z/znnNOKWUsBaCU$sha-1=cRseQyJpnuPGn3e6d6u6JdJWk.0,sha-256=5G
diff --git a/docs/lib/passlib.hash.scrypt.rst b/docs/lib/passlib.hash.scrypt.rst
index 6c2c061..19751ca 100644
--- a/docs/lib/passlib.hash.scrypt.rst
+++ b/docs/lib/passlib.hash.scrypt.rst
@@ -23,7 +23,7 @@ This class can be used directly as follows::
>>> from passlib.hash import scrypt
- >>> # generate new salt, encrypt password
+ >>> # generate new salt, hash password
>>> h = scrypt.hash("password")
>>> h
'$scrypt$ln=16,r=8,p=1$aM15713r3Xsvxbi31lqr1Q$nFNh2CVHVjNldFVKDHDlm4CbdRSCdEBsjjJxD+iCs5E'
diff --git a/docs/lib/passlib.hash.sha256_crypt.rst b/docs/lib/passlib.hash.sha256_crypt.rst
index b1e23e8..907ce7a 100644
--- a/docs/lib/passlib.hash.sha256_crypt.rst
+++ b/docs/lib/passlib.hash.sha256_crypt.rst
@@ -17,7 +17,7 @@ This class can be used directly as follows::
>>> from passlib.hash import sha256_crypt
- >>> # generate new salt, encrypt password
+ >>> # generate new salt, hash password
>>> hash = sha256_crypt.hash("password")
>>> hash
'$5$rounds=80000$wnsT7Yr92oJoP28r$cKhJImk5mfuSKV9b3mumNzlbstFUplKtQXXMo4G6Ep5'
diff --git a/docs/lib/passlib.hash.unix_disabled.rst b/docs/lib/passlib.hash.unix_disabled.rst
index 1159787..8bdf9c3 100644
--- a/docs/lib/passlib.hash.unix_disabled.rst
+++ b/docs/lib/passlib.hash.unix_disabled.rst
@@ -13,7 +13,7 @@ It can be used directly as follows::
>>> from passlib.hash import unix_disabled
- >>> # 'encrypting' a password always results in "!" or "*"
+ >>> # 'hashing' a password always results in "!" or "*"
>>> unix_disabled.hash("password")
'!'
diff --git a/docs/lib/passlib.hosts.rst b/docs/lib/passlib.hosts.rst
index d72fef0..811993d 100644
--- a/docs/lib/passlib.hosts.rst
+++ b/docs/lib/passlib.hosts.rst
@@ -3,10 +3,10 @@
============================================
.. module:: passlib.hosts
- :synopsis: encrypting & verifying operating system passwords
+ :synopsis: hashing & verifying operating system passwords
This module provides some preconfigured :ref:`CryptContext <context-reference>`
-instances for encrypting & verifying password hashes tied to user accounts of various operating systems.
+instances for hashing & verifying password hashes tied to user accounts of various operating systems.
While (most) of the objects are available cross-platform,
their use is oriented primarily towards Linux and BSD variants.
@@ -27,7 +27,7 @@ Each of the objects in this module can be imported directly::
>>> # which is configured to recognized most hashes found in Linux /etc/shadow files.
>>> from passlib.apps import linux_context
-Encrypting a password is simple (and salt generation is handled automatically)::
+Hashing a password is simple (and salt generation is handled automatically)::
>>> hash = linux_context.hash("toomanysecrets")
>>> hash
@@ -112,7 +112,7 @@ Current Host OS
are available on a given system (via ``host_context.schemes()``).
* it defaults to the strongest algorithm available,
automatically configured to an appropriate strength
- for encrypting new passwords.
+ for hashing new passwords.
* whereas :func:`!crypt` typically defaults to using
:mod:`~passlib.hash.des_crypt`; and provides little introspection.
diff --git a/docs/lib/passlib.ifc.rst b/docs/lib/passlib.ifc.rst
index 8118a4c..77ea440 100644
--- a/docs/lib/passlib.ifc.rst
+++ b/docs/lib/passlib.ifc.rst
@@ -270,7 +270,7 @@ using the provided configuration string.
:type config: unicode or bytes
:arg config:
- configuration string to use when encrypting secret.
+ configuration string to use when hashing the secret.
this can either be an existing hash that was previously
returned by :meth:`PasswordHash.genhash`, or a configuration string
that was previously created by :meth:`PasswordHash.genconfig`.
diff --git a/docs/narr/context-tutorial.rst b/docs/narr/context-tutorial.rst
index 718f031..8e4cb7a 100644
--- a/docs/narr/context-tutorial.rst
+++ b/docs/narr/context-tutorial.rst
@@ -87,7 +87,7 @@ interface, and hashing and verifying passwords is equally as straightforward::
True
If not told otherwise, the context object will use the first algorithm listed
-in ``schemes`` when encrypting new hashes. This default can be changed by
+in ``schemes`` when creating new hashes. This default can be changed by
using the ``default`` keyword::
>>> myctx = CryptContext(schemes=["sha256_crypt", "md5_crypt", "des_crypt"],
@@ -112,7 +112,7 @@ which probably provide a better argument for *why* you'd want to use it.
Using Default Settings
======================
-While encrypting and verifying hashes is useful enough, it's not much
+While creating and verifying hashes is useful enough, it's not much
more than could be done by importing the objects into a list.
The next feature of the :class:`!CryptContext` class is that it
can store various customized settings for the different algorithms,
@@ -409,7 +409,7 @@ All of the documented :ref:`context-options` are allowed.
pbkdf2_sha256__min_rounds = 10000
pbkdf2_sha256__max_rounds = 50000
- ; set the default rounds to use when encrypting new passwords.
+ ; set the default rounds to use when hashing new passwords.
pbkdf2_sha1__default_rounds = 15000
; applications can choose to treat certain user accounts differently,
diff --git a/docs/narr/hash-tutorial.rst b/docs/narr/hash-tutorial.rst
index 2407e63..b19de99 100644
--- a/docs/narr/hash-tutorial.rst
+++ b/docs/narr/hash-tutorial.rst
@@ -44,21 +44,19 @@ which fall into three general categories:
Hashing & Verifying
===================
-.. rst-class:: float-right without-title
+While all the hashers in :mod:`passlib.hash` offer a range of methods and attributes,
+the main activities applications will need to perform is hashing and verifying passwords.
+This can be done with the :meth:`PasswordHash.hash` and :meth:`PasswordHash.verify` methods.
+
+.. rst-class:: float-center without-title
.. caution::
**Changed in 1.7:**
- This section has changed under Passlib 1.7. Prior releases used
- :meth:`PasswordHash.encrypt`, which has now been renamed
- to :meth:`PasswordHash.hash`. A legacy alias is present in 1.7,
- but will be removed in Passlib 2.0.
-
-While all the hashers in :mod:`passlib.hash` offer a range of methods and attributes,
-the main activities applications will need to perform is hashing and verifying passwords.
-
-This can be done with the :meth:`PasswordHash.hash` and :meth:`PasswordHash.verify` methods.
+ Prior releases used :meth:`PasswordHash.encrypt` for hashing,
+ which has now been renamed to :meth:`PasswordHash.hash`.
+ A compatibility alias is present in 1.7, but will be removed in Passlib 2.0.
Hashing
-------
@@ -68,15 +66,15 @@ First, import the desired hash. The following example uses the :class:`~passlib
>>> # import the desired hasher
>>> from passlib.hash import pbkdf2_sha256
-Use :meth:`PasswordHash.hash` to hash a password. It takes care of unicode encoding,
-picking default rounds values::
+Use :meth:`PasswordHash.hash` to hash a password. This call takes care of unicode encoding,
+picking default rounds values, and generating a random salt::
>>> hash = pbkdf2_sha256.hash("password")
>>> hash
'$pbkdf2-sha256$29000$9t7be09prfXee2/NOUeotQ$Y.RDnnq8vsezSZSKy1QNy6xhKPdoBIwc.0XDdRm9sJ8'
-Note that each call generates a new salt, and thus the contents of the resulting
-hash will differ, despite using the same password::
+Note that since each call generates a new salt, the contents of the resulting
+hash will differ between calls (despite using the same password as input)::
>>> hash2 = pbkdf2_sha256.hash("password")
>>> hash2
@@ -98,45 +96,51 @@ against an existing hash::
Unicode & non-ASCII Characters
------------------------------
-Sidenote regarding unicode passwords & non-ASCII characters:
+*Sidenote regarding unicode passwords & non-ASCII characters:*
For the majority of hash algorithms and use-cases, passwords should
be provided as either :class:`!unicode` (or ``utf-8``-encoded :class:`!bytes`).
-One major exception legacy hashes that were generated
+One exception is legacy hashes that were generated
using a different character encoding. In this case, passwords should be
encoded using the correct encoding before they are passed to :meth:`!verify`;
otherwise users may not be able to log in successfully.
+For proper internationalization, applications should also take care to ensure
+unicode inputs are normalized to a single representation before hashing.
+The :func:`passlib.utils.saslprep` function can be used for this purpose.
+
.. _hash-configuring:
Customizing the Configuration
=============================
-.. rst-class:: float-right without-title
-.. caution::
+The using() Method
+------------------
+Each hasher contains a number of :ref:`informational attributes <informational-attributes>`.
+many of which can be customized to change the properties of the hashes
+generated by :meth:`PasswordHash.hash`. When you want to change the defaults,
+you don't have to modify the hasher class directly, or pass in the options to each call to :meth:`!PasswordHash.hash`.
- **Changed in 1.7:**
+Instead, all the hashes offer a :meth:`PasswordHash.using` method.
+This is a powerful method which accepts most hash informational attributes,
+as well as some other hash-specific configuration keywords; and returns
+a subclass of the original hasher (or a object with an identical interface).
+The returned object inherits the defaults settings from it's parent,
+but integrates any values you choose to override.
- This section has changed under Passlib 1.7. Prior releases required you
- to pass configuration options to each call of :meth:`PasswordHash.hash`
- That pattern is deprecated, and will be removed in Passlib 2.0;
- code should be switched to use :meth:`PasswordHash.using`...
+.. rst-class:: float-center without-title
-Each hasher contains a number of :ref:`informational attributes <informational-attributes>`,
-many of which can be customized to change the properties of the hashes
-generated by :meth:`PasswordHash.hash`.
+.. caution::
-Instead of modifying the hasher class directly, or having to pass in
-the options to each call to :meth:`!PasswordHash.hash`,
-all the hashes offer a :meth:`PasswordHash.using` method.
+ **Changed in 1.7:**
-This is a powerful method which accepts most hash informational attributes,
-as well as some other hash-specific configuration keywords; and returns
-a subclass of the original hasher (or an equivalent workalike). This object
-inherits the defaults from it's parent, but integrates any values you
-choose to override.
+ Prior releases required you to pass custom settings to each :meth:`PasswordHash.encrypt` call.
+ That usage pattern is deprecated, and will be removed in Passlib 2.0;
+ code should be switched to use :meth:`PasswordHash.using`, as shown below.
+Usage Example
+-------------
As an example, if the hasher you select supports a variable number of iterations
(such as :class:`~passlib.hash.pbkdf2_sha256`), you can specify a custom value
using the ``rounds`` keyword.
@@ -162,6 +166,8 @@ But if we call :meth:`PasswordHash.using`, we can override this value::
'$pbkdf2-sha256$123456$QwjBmJPSOsf4HyNE6L239g$8m1pnP69EYeOiKKb5sNSiYw9M8pJMyeW.CSm0KKO.GI'
^^^^^^
+Other Keywords
+--------------
While hashes frequently have additional keywords supported by using,
the basic set of settings you can customize can be found by inspecting
the :attr:`PasswordHash.setting_kwds` attribute::
@@ -169,7 +175,14 @@ the :attr:`PasswordHash.setting_kwds` attribute::
>>> pbkdf2_sha256.settings_kwds
("salt", "salt_size", "rounds")
-This method is additionally used internally by the :ref:`CryptContext <context-tutorial>`
+For instance, the following generates pbkdf2 hashes with a 32-byte salt
+instead of the default 16::
+
+ >>> pbkdf2_sha256.using(salt_size=8).hash("password")
+ '$pbkdf2-sha256$29000$tPZ.r5UyZgyhNEaI8Z5z7r1X6p1zTknJ.T/nHINwbq0$RlM49Qf5qRraHx.L7gq3hKIKSMLttrG1zWmWXyfXqc8'
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+This method is also used internally by the :ref:`CryptContext <context-tutorial>`
class it order to create a custom hasher configured based on the CryptContext policy
it was provided.
@@ -252,10 +265,14 @@ which determines whether a hash belongs to a given algorithm::
>>> pbkdf2_sha256.identify(other_hash)
False
-Note that most cases where an application will need to use this to
-sort out multiple hash formats, it will be more useful to switch to
-a :ref:`CryptContext <context-tutorial>` object, which handles this
-(and many similar tasks) automatically.
+.. rst-class:: float-center
+
+.. seealso::
+
+ In most cases where an application needs to
+ distinguish between multiple hash formats, it will be more useful to switch to
+ a :ref:`CryptContext <context-tutorial>` object, which automatically handles this
+ and many similar tasks.
.. todo::
diff --git a/docs/narr/overview.rst b/docs/narr/overview.rst
index 6aa73ec..03f1b16 100644
--- a/docs/narr/overview.rst
+++ b/docs/narr/overview.rst
@@ -16,10 +16,10 @@ as "hasher" classes which can be imported from the :mod:`passlib.hash` module.
In turn, all of the hashers have a uniform interface,
which is documented in the :ref:`hash-tutorial`.
-*A word of warning:* the hashes in this library marked as "insecure"
-are provided for historical purposes only. Still others are specialized in ways that are not generally useful.
+*A word of warning:* Some the hashes in this library are marked as "insecure",
+and are provided for historical purposes only. Still others are specialized in ways that are not generally useful.
If you are creating a new application and need to choose a password hash,
-see the :doc:`quickstart`.
+please read the :doc:`quickstart` first.
.. rst-class:: float-center
@@ -43,8 +43,8 @@ Over time, they have to support a number of tasks:
In these situations, loading and handling multiple hash algorithms becomes
complicated and tedious. The :mod:`passlib.context` module provides a single class,
-:class:`!CryptContext`, which attempts to solve all of these problems...
-or at least relieve applications developers of (most of) the burden.
+:class:`!CryptContext`, which attempts to solve all of these problems
+(or at least relieve developers of most of the burden).
This class handles managing multiple password hash schemes,
deprecation & migration of old hashes, and supports a simple configuration
diff --git a/docs/narr/quickstart.rst b/docs/narr/quickstart.rst
index 8e2570e..cfdd730 100644
--- a/docs/narr/quickstart.rst
+++ b/docs/narr/quickstart.rst
@@ -3,8 +3,8 @@ New Application Quickstart Guide
================================
Need to quickly get password hash support added into your new application,
-and don't have time to wade through pages of documentation,
-comparing and contrasting all the different schemes? Read on...
+butdon't have time to wade through pages of documentation,
+comparing and contrasting all the different schemes? Then read on...
..
NOTE: commented this out for now, considering deprecating
@@ -24,13 +24,13 @@ comparing and contrasting all the different schemes? Read on...
>>> # import the context under an app-specific name (so it can easily be replaced later)
>>> from passlib.apps import custom_app_context as pwd_context
- >>> # encrypting a password...
+ >>> # hash a password...
>>> hash = pwd_context.hash("somepass")
>>> # verifying a password...
>>> ok = pwd_context.verify("somepass", hash)
- >>> # [optional] encrypting a password for an admin account...
+ >>> # [optional] hashing a password for an admin account...
>>> # the custom_app_context is preconfigured so that
>>> # if the category is set to "admin" instead of None,
>>> # it uses a stronger setting of 80000 rounds:
@@ -266,7 +266,7 @@ To start using your CryptContext, import the context you created wherever it's n
>>> # import context from where you defined it...
>>> from myapp.model.security import pwd_context
- >>> # encrypting a password...
+ >>> # hashing a password...
>>> hash = pwd_context.hash("somepass")
>>> hash
'$pbkdf2-sha256$29000$BSBkLEXIeS9FKMW4F.I85w$SJMzqVU7fw49NDOJZHt2o9vKIfDUVM4cKlAD4MxIgD0'
diff --git a/passlib/apache.py b/passlib/apache.py
index 41a4315..af1fb8b 100644
--- a/passlib/apache.py
+++ b/passlib/apache.py
@@ -618,7 +618,7 @@ class HtpasswdFile(_CommonFile):
:type context: :class:`~passlib.context.CryptContext`
:param context:
- :class:`!CryptContext` instance used to encrypt
+ :class:`!CryptContext` instance used to create
and verify the hashes found in the htpasswd file.
The default value is a pre-built context which supports all
of the hashes officially allowed in an htpasswd file.
@@ -643,7 +643,7 @@ class HtpasswdFile(_CommonFile):
in Passlib 1.8.
:param default:
- Change the default algorithm used to encrypt new passwords.
+ Change the default algorithm used to hash new passwords.
.. deprecated:: 1.6
This has been renamed to *default_scheme* for clarity.
diff --git a/passlib/exc.py b/passlib/exc.py
index e2af9ff..95a0707 100644
--- a/passlib/exc.py
+++ b/passlib/exc.py
@@ -261,7 +261,7 @@ def ExpectedStringError(value, param):
return ExpectedTypeError(value, "unicode or bytes", param)
#------------------------------------------------------------------------
-# encrypt/verify parameter errors
+# hash/verify parameter errors
#------------------------------------------------------------------------
def MissingDigestError(handler=None):
"""raised when verify() method gets passed config string instead of hash"""
diff --git a/passlib/handlers/md5_crypt.py b/passlib/handlers/md5_crypt.py
index fc1fb1d..993db4d 100644
--- a/passlib/handlers/md5_crypt.py
+++ b/passlib/handlers/md5_crypt.py
@@ -48,7 +48,7 @@ def _raw_md5_crypt(pwd, salt, use_apr=False):
for the MD5-Crypt algorithms; it doesn't handle any of the
parsing/validation of the hash strings themselves.
- :arg pwd: password chars/bytes to encrypt
+ :arg pwd: password chars/bytes to hash
:arg salt: salt chars to use
:arg use_apr: use apache variant
diff --git a/passlib/handlers/misc.py b/passlib/handlers/misc.py
index c133651..44abc34 100644
--- a/passlib/handlers/misc.py
+++ b/passlib/handlers/misc.py
@@ -29,8 +29,8 @@ class unix_fallback(uh.ifc.DisabledHash, uh.StaticHandler):
behavior as found in /etc/shadow on most unix variants.
If used, should be the last scheme in the context.
- * this class will positive identify all hash strings.
- * for security, newly encrypted passwords will hash to ``!``.
+ * this class will positively identify all hash strings.
+ * for security, passwords will always hash to ``!``.
* it rejects all passwords if the hash is NOT an empty string (``!`` or ``*`` are frequently used).
* by default it rejects all passwords if the hash is an empty string,
but if ``enable_wildcard=True`` is passed to verify(),
diff --git a/passlib/handlers/sha2_crypt.py b/passlib/handlers/sha2_crypt.py
index d12e3f1..807de5e 100644
--- a/passlib/handlers/sha2_crypt.py
+++ b/passlib/handlers/sha2_crypt.py
@@ -60,7 +60,7 @@ def _raw_sha2_crypt(pwd, salt, rounds, use_512=False):
for the SHA256-Crypt and SHA512-Crypt algorithms; it doesn't
handle any of the parsing/validation of the hash strings themselves.
- :arg pwd: password chars/bytes to encrypt
+ :arg pwd: password chars/bytes to hash
:arg salt: salt chars to use
:arg rounds: linear rounds cost
:arg use_512: use sha512-crypt instead of sha256-crypt mode
diff --git a/passlib/tests/test_context.py b/passlib/tests/test_context.py
index 08863e8..7ad26cd 100644
--- a/passlib/tests/test_context.py
+++ b/passlib/tests/test_context.py
@@ -879,7 +879,7 @@ sha512_crypt__min_rounds = 45000
]
def test_40_basic(self):
- """test basic encrypt/identify/verify functionality"""
+ """test basic hash/identify/verify functionality"""
handlers = [hash.md5_crypt, hash.des_crypt, hash.bsdi_crypt]
cc = CryptContext(handlers, bsdi_crypt__default_rounds=5)
@@ -934,7 +934,7 @@ sha512_crypt__min_rounds = 45000
#--------------------------------------------------------------
# test unicode category strings are accepted under py2
- # this tests basic _get_record() used by encrypt/genhash/verify.
+ # this tests basic _get_record() used by hash/genhash/verify.
# we have to omit scheme=xxx so codepath is tested fully
if PY2:
c2 = cc.copy(default="phpass")
@@ -1036,30 +1036,31 @@ sha512_crypt__min_rounds = 45000
# and then discard the rest of these under 2.0.
# hash specific settings
- self.assertEqual(
- cc.hash("password", scheme="phpass", salt='.'*8),
- '$H$5........De04R5Egz0aq8Tf.1eVhY/',
- )
- self.assertEqual(
- cc.hash("password", scheme="phpass", salt='.'*8, ident="P"),
- '$P$5........De04R5Egz0aq8Tf.1eVhY/',
- )
+ with self.assertWarningList(["passing settings to.*is deprecated"]):
+ self.assertEqual(
+ cc.hash("password", scheme="phpass", salt='.'*8),
+ '$H$5........De04R5Egz0aq8Tf.1eVhY/',
+ )
+ with self.assertWarningList(["passing settings to.*is deprecated"]):
+ self.assertEqual(
+ cc.hash("password", scheme="phpass", salt='.'*8, ident="P"),
+ '$P$5........De04R5Egz0aq8Tf.1eVhY/',
+ )
# NOTE: more thorough job of rounds limits done below.
# min rounds
- with self.assertWarningList([]):
+ with self.assertWarningList(["passing settings to.*is deprecated"]):
self.assertEqual(
cc.hash("password", rounds=1999, salt="nacl"),
'$5$rounds=1999$nacl$nmfwJIxqj0csloAAvSER0B8LU0ERCAbhmMug4Twl609',
)
- with self.assertWarningList([]):
+ with self.assertWarningList(["passing settings to.*is deprecated"]):
self.assertEqual(
cc.hash("password", rounds=2001, salt="nacl"),
'$5$rounds=2001$nacl$8PdeoPL4aXQnJ0woHhqgIw/efyfCKC2WHneOpnvF.31'
)
-
# NOTE: max rounds, etc tested in genconfig()
# bad scheme values
@@ -1294,7 +1295,8 @@ sha512_crypt__min_rounds = 45000
self.assertEqual(cc1.verify_and_update("stub", des_hash), (True, None))
# des_crypt should throw error due to unknown context keyword
- self.assertRaises(TypeError, cc1.hash, "stub", user="root")
+ with self.assertWarningList(["passing settings to.*is deprecated"]):
+ self.assertRaises(TypeError, cc1.hash, "stub", user="root")
self.assertRaises(TypeError, cc1.verify, "stub", des_hash, user="root")
self.assertRaises(TypeError, cc1.verify_and_update, "stub", des_hash, user="root")
@@ -1315,7 +1317,8 @@ sha512_crypt__min_rounds = 45000
self.assertEqual(cc2.verify_and_update("stub", des_hash, user="root"), (True, None))
# verify error with unknown kwd
- self.assertRaises(TypeError, cc2.hash, "stub", badkwd="root")
+ with self.assertWarningList(["passing settings to.*is deprecated"]):
+ self.assertRaises(TypeError, cc2.hash, "stub", badkwd="root")
self.assertRaises(TypeError, cc2.verify, "stub", des_hash, badkwd="root")
self.assertRaises(TypeError, cc2.verify_and_update, "stub", des_hash, badkwd="root")
diff --git a/passlib/tests/test_ext_django.py b/passlib/tests/test_ext_django.py
index 79d19df..25513fc 100644
--- a/passlib/tests/test_ext_django.py
+++ b/passlib/tests/test_ext_django.py
@@ -137,8 +137,9 @@ stock_config.update(
# override sample hashes used in test cases
from passlib.hash import django_pbkdf2_sha256
sample_hashes = dict(
- django_pbkdf2_sha256=("not a password", django_pbkdf2_sha256.hash("not a password",
- rounds=stock_config.get("django_pbkdf2_sha256__default_rounds")))
+ django_pbkdf2_sha256=("not a password", django_pbkdf2_sha256
+ .using(rounds=stock_config.get("django_pbkdf2_sha256__default_rounds"))
+ .hash("not a password"))
)
#=============================================================================
diff --git a/passlib/tests/test_handlers_pbkdf2.py b/passlib/tests/test_handlers_pbkdf2.py
index 9a7036a..4d2f048 100644
--- a/passlib/tests/test_handlers_pbkdf2.py
+++ b/passlib/tests/test_handlers_pbkdf2.py
@@ -334,7 +334,7 @@ class scram_test(HandlerCase):
def test_93_derive_digest(self):
"""test scram.derive_digest()"""
# NOTE: this just does a light test, since derive_digest
- # is used by encrypt / verify, and is tested pretty well via those.
+ # is used by hash / verify, and is tested pretty well via those.
hash = self.handler.derive_digest
# check various encodings of password work.
@@ -357,17 +357,17 @@ class scram_test(HandlerCase):
self.assertEqual(hash(u("IX"), s1.decode("latin-1"), 1000, 'sha1'), d1)
def test_94_saslprep(self):
- """test encrypt/verify use saslprep"""
+ """test hash/verify use saslprep"""
# NOTE: this just does a light test that saslprep() is being
# called in various places, relying in saslpreps()'s tests
# to verify full normalization behavior.
- # encrypt unnormalized
+ # hash unnormalized
h = self.do_encrypt(u("I\u00ADX"))
self.assertTrue(self.do_verify(u("IX"), h))
self.assertTrue(self.do_verify(u("\u2168"), h))
- # encrypt normalized
+ # hash normalized
h = self.do_encrypt(u("\xF3"))
self.assertTrue(self.do_verify(u("o\u0301"), h))
self.assertTrue(self.do_verify(u("\u200Do\u0301"), h))
@@ -389,7 +389,7 @@ class scram_test(HandlerCase):
# should have own set
self.assertEqual(subcls.default_algs, ["md5", "sha-1"])
- # test encrypt output
+ # test hash output
h1 = subcls.hash("dummy")
self.assertEqual(handler.extract_digest_algs(h1), ["md5", "sha-1"])
diff --git a/passlib/tests/test_utils_handlers.py b/passlib/tests/test_utils_handlers.py
index ce65884..19cd4ca 100644
--- a/passlib/tests/test_utils_handlers.py
+++ b/passlib/tests/test_utils_handlers.py
@@ -86,7 +86,7 @@ class SkeletonTest(TestCase):
self.assertRaises(ValueError, d1.verify, 's', b'_c')
self.assertRaises(ValueError, d1.verify, 's', u('_c'))
- # check default encrypt method
+ # check default hash method
self.assertEqual(d1.hash('s'), '_a')
self.assertEqual(d1.hash('s', flag=True), '_b')
@@ -126,7 +126,7 @@ class SkeletonTest(TestCase):
raise ValueError("no hash specified")
return cls.genhash(secret, hash) == hash.lower()
- # encrypt should issue api warnings, but everything else should be fine.
+ # hash should issue api warnings, but everything else should be fine.
with self.assertWarningList("d1.*should be updated.*_calc_checksum"):
hash = d1.hash("test")
self.assertEqual(hash, '7c622762588a0e5cc786ad0a143156f9fd38eea3')
@@ -708,7 +708,7 @@ class PrefixWrapperTest(TestCase):
self.assertEqual(d1.genhash("password", dph), dph)
self.assertRaises(ValueError, d1.genhash, "password", lph)
- # encrypt
+ # hash
self.assertEqual(d1.hash("password"), dph)
# identify
diff --git a/passlib/tests/utils.py b/passlib/tests/utils.py
index 0d64b09..235fd76 100644
--- a/passlib/tests/utils.py
+++ b/passlib/tests/utils.py
@@ -362,6 +362,10 @@ class TestCase(_TestCase):
ctx = reset_warnings()
ctx.__enter__()
self.addCleanup(ctx.__exit__)
+
+ # ignore warnings about PasswordHash features deprecated in 1.7
+ # TODO: should be cleaned in 2.0, when support will be dropped.
+ # should be kept until then, so we test the legacy paths.
warnings.filterwarnings("ignore", "the method .*\.(encrypt|genconfig|genhash)\(\) is deprecated")
warnings.filterwarnings("ignore", "the 'vary_rounds' option is deprecated")
@@ -730,7 +734,7 @@ class HandlerCase(TestCase):
"vt0RLE8uZ4oPwcelCjmw2kSYu.Ec6ycULevoBK25fs2xXgMNrCzIMVcgEJAstJeonj1"),
]
- # passwords used to test basic encrypt behavior - generally
+ # passwords used to test basic hash behavior - generally
# don't need to be overidden.
stock_passwords = [
u("test"),
@@ -862,8 +866,12 @@ class HandlerCase(TestCase):
secret = self.populate_context(secret, context)
if use_encrypt:
# use legacy 1.6 api
- context.update(**settings)
- return (handler or self.handler).encrypt(secret, **context)
+ warnings = []
+ if settings:
+ context.update(**settings)
+ warnings.append("passing settings to.*is deprecated")
+ with self.assertWarningList(warnings):
+ return (handler or self.handler).encrypt(secret, **context)
else:
# use 1.7 api
return (handler or self.handler).using(**settings).hash(secret, **context)
@@ -1352,7 +1360,7 @@ class HandlerCase(TestCase):
return salt
def test_14_salt_chars(self):
- """test encrypt() honors salt_chars"""
+ """test hash() honors salt_chars"""
self.require_salt_info()
handler = self.handler
@@ -3069,7 +3077,7 @@ class UserHandlerMixin(HandlerCase):
"""helper for handlers w/ 'user' context kwd; mixin for HandlerCase
this overrides the HandlerCase test harness methods
- so that a username is automatically inserted to encrypt/verify
+ so that a username is automatically inserted to hash/verify
calls. as well, passing in a pair of strings as the password
will be interpreted as (secret,user)
"""
@@ -3166,7 +3174,7 @@ class EncodingHandlerMixin(HandlerCase):
"""helper for handlers w/ 'encoding' context kwd; mixin for HandlerCase
this overrides the HandlerCase test harness methods
- so that an encoding can be inserted to encrypt/verify
+ so that an encoding can be inserted to hash/verify
calls by passing in a pair of strings as the password
will be interpreted as (secret,encoding)
"""
diff --git a/passlib/utils/__init__.py b/passlib/utils/__init__.py
index 1be8a47..fcc9686 100644
--- a/passlib/utils/__init__.py
+++ b/passlib/utils/__init__.py
@@ -402,13 +402,16 @@ def saslprep(source, param="value"):
unicode string to normalize & validate
:param param:
- Optional noun used to refer to identify source parameter in error messages
+ Optional noun identifying source parameter in error messages
(Defaults to the string ``"value"``). This is mainly useful to make the caller's error
- messages make more sense.
+ messages make more sense contextually.
:raises ValueError:
if any characters forbidden by the SASLPrep profile are encountered.
+ :raises TypeError:
+ if input is not :class:`!unicode`
+
:returns:
normalized unicode string
@@ -425,6 +428,8 @@ def saslprep(source, param="value"):
# http://docs.python.org/library/stringprep.html
# validate type
+ # XXX: support bytes (e.g. run through want_unicode)?
+ # might be easier to just integrate this into cryptcontext.
if not isinstance(source, unicode):
raise TypeError("input must be unicode string, not %s" %
(type(source),))
diff --git a/passlib/utils/handlers.py b/passlib/utils/handlers.py
index 1d7c257..a0c1f51 100644
--- a/passlib/utils/handlers.py
+++ b/passlib/utils/handlers.py
@@ -89,7 +89,7 @@ def guess_app_stacklevel(start=1):
try:
while frame:
name = frame.f_globals.get('__name__', "")
- if not name.startswith("passlib.") or name.startswith("passlib.tests."):
+ if name.startswith("passlib.tests.") or not name.startswith("passlib."):
return max(1, count)
count += 1
frame = frame.f_back
@@ -100,7 +100,7 @@ def guess_app_stacklevel(start=1):
def warn_hash_settings_deprecation(handler, kwds):
warn("passing settings to %(handler)s.hash() is deprecated, and won't be supported in Passlib 2.0; "
"use '%(handler)s.using(**settings).hash(secret)' instead" % dict(handler=handler.name),
- stacklevel=guess_app_stacklevel(2))
+ DeprecationWarning, stacklevel=guess_app_stacklevel(2))
def extract_settings_kwds(handler, kwds):
"""
@@ -538,7 +538,7 @@ class GenericHandler(MinimalHandler):
.. automethod:: genconfig
.. automethod:: genhash
.. automethod:: identify
- .. automethod:: encrypt
+ .. automethod:: hash
.. automethod:: verify
"""
@@ -731,8 +731,7 @@ class GenericHandler(MinimalHandler):
# this block of code.
settings = extract_settings_kwds(cls, kwds)
if settings:
- # TODO: uncomment this ones UTs are adjusted to expect warning...
- # warn_hash_settings_deprecation(cls, settings)
+ warn_hash_settings_deprecation(cls, settings)
return cls.using(**settings).hash(secret, **kwds)
# NOTE: at this point, 'kwds' should just contain context_kwds subset
validate_secret(secret)
@@ -845,7 +844,7 @@ class GenericHandler(MinimalHandler):
"""
# FIXME: this may not work for hashes with non-standard settings.
# XXX: how should this handle checksum/salt encoding?
- # need to work that out for encrypt anyways.
+ # need to work that out for hash() anyways.
self = cls.from_string(hash)
# XXX: could split next few lines out as self._parsehash() for subclassing
# XXX: could try to resolve ident/variant to publically suitable alias.