This instance was upgraded to Heptapod 0.20.1 today

Commit e0e8567d authored by Eli Collins's avatar Eli Collins

.encrypt() method renamed to .hash(), other api cleanups

.encrypt()
----------
hash.encrypt() & context.encrypt() have been renamed to .hash().
this should take care of the long-standing issue 21 (the poor naming of .encrypt).
per docs, legacy aliases will remain in place until passlib 2.0.

.genhash() / .genconfig()
-------------------------
taking advantage of this reorganization to also deprecate .genconfig()
and .genhash() -- they're not really useful in a modern system,
nor as needed for historical support as initially thought:
.genconfig() will be retired completely in passlib 2.0;
.genhash() is rolled into the new .hash() method along with .encrypt().
parent 070364a99ca7
......@@ -96,6 +96,22 @@ Minor Internal Changes
Deprecations
------------
* The :class:`~passlib.context.CryptContext` object, and the :class:`~passlib.ifc.PasswordHash` api
used by all hashes in passlib, have had a number of cleanups made:
* :meth:`!encrypt` has been renamed to :meth:`~passlib.ifc.PasswordHash.hash`,
to clarify that it's performing one-way hashing rather than encryption.
A compatibility alias will remain in place until Passlib 2.0.
This should fix the longstanding :issue:`21`.
* The little-used methods :meth:`~passlib.ifc.PasswordHash.genhash` and
:meth:`~passlib.ifc.PasswordHash.genconfig` have been deprecated.
Compatibility aliases will remain in place until Passlib 2.0.
* In order for :meth:`~passlib.ifc.PasswordHash.hash` to take over the job
previously performed by :meth:`~passlib.ifc.PasswordHash.genhash`, it now accepts
a keyword ``"config"``, which specifies an existing hash to extract configuration from.
* The :func:`~passlib.utils.generate_secret` function has been deprecated
in favor of the new :mod:`passlib.pwd` module, and the old function will be removed
in Passlib 2.0.
......@@ -112,7 +128,6 @@ Deprecations
Backwards Incompatibilities
---------------------------
* :func:`passlib.utils.pbkdf2.pbkdf2` no longer supports custom PRF callables.
this was an unused feature, and prevented some useful optimizations.
......@@ -125,6 +140,10 @@ Backwards Incompatibilities
algorithm available on the host, rather than one that is guaranteed to be portable.
Applications can explicitly set ``default_scheme="portable"`` to retain the old behavior.
* The little-used method :meth:`~passlib.ifc.PasswordHash.genconfig` method
will now always return a valid hash, rather than a truncated configuration
hash or ``None``. This should affect nearly 0 applications.
**1.6.6** (NOT YET RELEASED)
============================
......
......@@ -34,7 +34,7 @@ A quick example of using passlib to integrate into a new application::
>>> from passlib.apps import custom_app_context as pwd_context
>>> # encrypting a password...
>>> hash = pwd_context.encrypt("somepass")
>>> hash = pwd_context.hash("somepass")
>>> hash
'$6$rounds=36122$kzMjVFTjgSVuPoS.$zx2RoZ2TYRHoKn71Y60MFmyqNPxbNnTZdwYD8y2atgoRIp923WJSbcbQc6Af3osdW96MRfwb5Hk7FymOM6D7J1'
......
......@@ -201,7 +201,7 @@ def test_context_calls():
another__vary_rounds=100,
)
def helper():
hash = ctx.encrypt(SECRET, rounds=2001)
hash = ctx.hash(SECRET, rounds=2001)
ctx.verify(SECRET, hash)
ctx.verify_and_update(SECRET, hash)
ctx.verify_and_update(OTHER, hash)
......@@ -219,7 +219,7 @@ def test_bcrypt_builtin():
bcrypt.set_backend("builtin")
bcrypt.default_rounds = 10
def helper():
hash = bcrypt.encrypt(SECRET)
hash = bcrypt.hash(SECRET)
bcrypt.verify(SECRET, hash)
bcrypt.verify(OTHER, hash)
return helper
......@@ -231,7 +231,7 @@ def test_bcrypt_ffi():
bcrypt.set_backend("bcrypt")
bcrypt.default_rounds = 8
def helper():
hash = bcrypt.encrypt(SECRET)
hash = bcrypt.hash(SECRET)
bcrypt.verify(SECRET, hash)
bcrypt.verify(OTHER, hash)
return helper
......@@ -242,7 +242,7 @@ def test_md5_crypt_builtin():
from passlib.hash import md5_crypt
md5_crypt.set_backend("builtin")
def helper():
hash = md5_crypt.encrypt(SECRET)
hash = md5_crypt.hash(SECRET)
md5_crypt.verify(SECRET, hash)
md5_crypt.verify(OTHER, hash)
return helper
......@@ -252,7 +252,7 @@ def test_ldap_salted_md5():
"""test ldap_salted_md5"""
from passlib.hash import ldap_salted_md5 as handler
def helper():
hash = handler.encrypt(SECRET, salt='....')
hash = handler.hash(SECRET, salt='....')
handler.verify(SECRET, hash)
handler.verify(OTHER, hash)
return helper
......@@ -263,7 +263,7 @@ def test_phpass():
from passlib.hash import phpass as handler
kwds = dict(salt='.'*8, rounds=16)
def helper():
hash = handler.encrypt(SECRET, **kwds)
hash = handler.hash(SECRET, **kwds)
handler.verify(SECRET, hash)
handler.verify(OTHER, hash)
return helper
......@@ -273,7 +273,7 @@ def test_sha1_crypt():
from passlib.hash import sha1_crypt as handler
kwds = dict(salt='.'*8, rounds=10000)
def helper():
hash = handler.encrypt(SECRET, **kwds)
hash = handler.hash(SECRET, **kwds)
handler.verify(SECRET, hash)
handler.verify(OTHER, hash)
return helper
......
......@@ -103,7 +103,7 @@ def main(*args):
"""estimate speed using specified # of rounds"""
# time a single verify() call
secret = "S0m3-S3Kr1T"
hash = hasher.encrypt(secret, rounds=rounds)
hash = hasher.hash(secret, rounds=rounds)
def helper():
start = tick()
hasher.verify(secret, hash)
......
......@@ -28,7 +28,7 @@ using the :doc:`SHA256-Crypt </lib/passlib.hash.sha256_crypt>` algorithm::
>>> from passlib.hash import sha256_crypt
>>> # generate new salt, and hash a password
>>> hash = sha256_crypt.encrypt("toomanysecrets")
>>> hash = sha256_crypt.hash("toomanysecrets")
>>> hash
'$5$rounds=80000$zvpXD3gCkrt7tw.1$QqeTSolNHEfgryc5oMgiq1o8qCEAcmye3FoMSuvgToC'
......
......@@ -25,7 +25,7 @@ Each of the objects in this module can be imported directly::
Encrypting a password is simple (and salt generation is handled automatically)::
>>> hash = custom_app_context.encrypt("toomanysecrets")
>>> hash = custom_app_context.hash("toomanysecrets")
>>> hash
'$5$rounds=84740$fYChCy.52EzebF51$9bnJrmTf2FESI93hgIBFF4qAfysQcKoB0veiI0ZeYU4'
......@@ -116,7 +116,7 @@ Passlib provides two contexts related to ldap hashes:
>>> ldap_context = ldap_context.replace(default="ldap_salted_md5")
>>> # the new context object will now default to {SMD5}:
>>> ldap_context.encrypt("password")
>>> ldap_context.hash("password")
'{SMD5}T9f89F591P3fFh1jz/YtW4aWD5s='
.. data:: ldap_nocrypt_context
......@@ -190,7 +190,7 @@ PostgreSQL
>>> from passlib.apps import postgres_context
>>> # encrypting a password...
>>> postgres_context.encrypt("somepass", user="dbadmin")
>>> postgres_context.hash("somepass", user="dbadmin")
'md578ed0f0ab2be0386645c1b74282917e7'
>>> # verifying a password...
......@@ -200,7 +200,7 @@ PostgreSQL
False
>>> # forgetting the user will result in an error:
>>> postgres_context.encrypt("somepass")
>>> postgres_context.hash("somepass")
Traceback (most recent call last):
<traceback omitted>
TypeError: user must be unicode or bytes, not None
......
......@@ -66,7 +66,7 @@ interface, and hashing and verifying passwords is equally as straightforward::
>>> # this loads first algorithm in the schemes list (sha256_crypt),
>>> # generates a new salt, and hashes the password:
>>> hash1 = myctx.encrypt("joshua")
>>> hash1 = myctx.hash("joshua")
>>> hash1
'$5$rounds=80000$HFEGd1wnFknpibRl$VZqjyYcTenv7CtOf986hxuE0pRaGXnuLXyfb7m9xL69'
......@@ -78,7 +78,7 @@ interface, and hashing and verifying passwords is equally as straightforward::
>>> # alternately, you can explicitly pick one of the configured algorithms,
>>> # through this is rarely needed in practice:
>>> hash2 = myctx.encrypt("dogsnamehere", scheme="md5_crypt")
>>> hash2 = myctx.hash("dogsnamehere", scheme="md5_crypt")
>>> hash2
'$1$e2nig/AC$stejMS1ek6W0/UogYKFao/'
......@@ -93,7 +93,7 @@ using the ``default`` keyword::
>>> myctx = CryptContext(schemes=["sha256_crypt", "md5_crypt", "des_crypt"],
default="des_crypt")
>>> hash = myctx.encrypt("password")
>>> hash = myctx.hash("password")
>>> hash
'bIwNofDzt1LCY'
......@@ -106,7 +106,7 @@ which probably provide a better argument for *why* you'd want to use it.
.. seealso::
* the :meth:`CryptContext.encrypt`, :meth:`~CryptContext.verify`, and :meth:`~CryptContext.identify` methods.
* the :meth:`CryptContext.hash`, :meth:`~CryptContext.verify`, and :meth:`~CryptContext.identify` methods.
* the :ref:`schemes <context-schemes-option>` and :ref:`default <context-default-option>` constructor options.
.. _context-default-settings-example:
......@@ -127,12 +127,12 @@ and the :class:`ldap_salted_md5 <passlib.hash.ldap_salted_md5>` algorithm uses
>>> myctx = CryptContext(["sha256_crypt", "ldap_salted_md5"])
>>> # sha256_crypt using 80000 rounds...
>>> myctx.encrypt("password", scheme="sha256_crypt")
>>> myctx.hash("password", scheme="sha256_crypt")
'$5$rounds=80000$GgU/gwNBs9SaObqs$ohY23/zm.8O0TpkGx5fxk0aeVdFpaeKo9GUkMJ0VrMC'
^^^^^
>>> # ldap_salted_md5 with an 8 byte salt...
>>> myctx.encrypt("password", scheme="ldap_salted_md5")
>>> myctx.hash("password", scheme="ldap_salted_md5")
'{SMD5}cIYrPh5f/TeUKg9oghECB5fSeu8='
^^^^^^^^^^
......@@ -148,11 +148,11 @@ These is done by passing the CryptContext constructor a keyword with the format
... ldap_salted_md5__salt_size=16)
>>> # the effect of this can be seen the next time encrypt is called:
>>> myctx.encrypt("password", scheme="sha256_crypt")
>>> myctx.hash("password", scheme="sha256_crypt")
'$5$rounds=91234$GgU/gwNBs9SaObqs$ohY23/zm.8O0TpkGx5fxk0aeVdFpaeKo9GUkMJ0VrMC'
^^^^^
>>> myctx.encrypt("password", scheme="ldap_salted_md5")
>>> myctx.hash("password", scheme="ldap_salted_md5")
'{SMD5}NnQh2S2pjnFxwtMhjbVH59TaG6P0/l/r3RsDwPj/n/M='
^^^^^^^^^^^^^^^^^^^^^
......@@ -288,7 +288,7 @@ perform can be combined into the following bit of skeleton code:
hash = get_hash_from_user(user)
if pass_ctx.verify(password, hash):
if pass_ctx.needs_update(hash):
new_hash = pass_ctx.encrypt(password)
new_hash = pass_ctx.hash(password)
replace_user_hash(user, new_hash)
do_successful_things()
else:
......@@ -340,7 +340,7 @@ New hashes generated by this context will always honor the minimum
(just as if ``default_rounds`` was set to the same value)::
>>> # plain call to encrypt:
>>> hash1 = myctx.encrypt("password")
>>> hash1 = myctx.hash("password")
'$5$rounds=131072$i6xuFK6j8r66ahGn$r.7H8HUk30qiH7fIWRJFJfhWG925nRZh90aYPMdewr3'
^^^^^^
>>> # hashes with enough rounds won't show up as deprecated...
......@@ -351,7 +351,7 @@ Explicitly setting the rounds too low will cause a warning,
and the minimum will be used anyways::
>>> # explicit rounds passed to encrypt...
>>> myctx.encrypt("password", rounds=1000)
>>> myctx.hash("password", rounds=1000)
__main__:1: PasslibConfigWarning: sha256_crypt config requires rounds >= 131072,
increasing value from 80000
'$5$rounds=131072$86YrzUF3fGwY99oy$03e/pyh4l3N/G0509er9JiQmIxc0y9lrAJaLswX/iv8'
......@@ -494,7 +494,7 @@ the following code in the correct function::
# 'category' containing a category assigned to the user account
#
hash = user_pwd_context.encrypt(secret, category=category)
hash = user_pwd_context.hash(secret, category=category)
#... perform appropriate actions to store hash...
......
......@@ -68,7 +68,7 @@ Options which directly affect the behavior of the CryptContext instance:
The most important option in the constructor,
This option controls what hashes can be used
by the :meth:`~CryptContext.encrypt` method,
by the :meth:`~CryptContext.hash` method,
which hashes will be recognized by :meth:`~CryptContext.verify`
and :meth:`~CryptContext.identify`, and other effects
throughout the instance.
......@@ -109,23 +109,23 @@ Options which directly affect the behavior of the CryptContext instance:
You can use the :meth:`~CryptContext.default_scheme` method
to retrieve the name of the current default scheme.
As an example, the following demonstrates the effect
of this parameter on the :meth:`~CryptContext.encrypt`
of this parameter on the :meth:`~CryptContext.hash`
method::
>>> from passlib.context import CryptContext
>>> myctx = CryptContext(schemes=["sha256_crypt", "md5_crypt"])
>>> # encrypt() uses the first scheme
>>> # hash() uses the first scheme
>>> myctx.default_scheme()
'sha256_crypt'
>>> myctx.encrypt("password")
>>> myctx.hash("password")
'$5$rounds=80000$R5ZIZRTNPgbdcWq5$fT/Oeqq/apMa/0fbx8YheYWS6Z3XLTxCzEtutsk2cJ1'
>>> # but setting default causes the second scheme to be used.
>>> myctx.update(default="md5_crypt")
>>> myctx.default_scheme()
'md5_crypt'
>>> myctx.encrypt("password")
>>> myctx.hash("password")
'$1$Rr0C.KI8$Kvciy8pqfL9BQ2CJzEzfZ/'
.. seealso:: the :ref:`context-basic-example` example in the tutorial.
......@@ -184,7 +184,7 @@ in ``schemes``, and :samp:`{option}` one of the parameters below:
:samp:`{scheme}__default_rounds`
Sets the default number of rounds to use with this scheme
when generating new hashes (using :meth:`~CryptContext.encrypt`).
when generating new hashes (using :meth:`~CryptContext.hash`).
If not set, this will fall back to the an algorithm-specific
:attr:`~passlib.ifc.PasswordHash.default_rounds`.
......@@ -193,15 +193,15 @@ in ``schemes``, and :samp:`{option}` one of the parameters below:
>>> from passlib.context import CryptContext
>>> # no explicit default_rounds set, so encrypt() uses sha256_crypt's default (80000)
>>> # no explicit default_rounds set, so hash() uses sha256_crypt's default (80000)
>>> myctx = CryptContext(["sha256_crypt"])
>>> myctx.encrypt("fooey")
>>> myctx.hash("fooey")
'$5$rounds=80000$60Y7mpmAhUv6RDvj$AdseAOq6bKUZRDRTr/2QK1t38qm3P6sYeXhXKnBAmg0'
^^^^^
>>> # but if a default is specified, it will be used instead.
>>> myctx = CryptContext(["sha256_crypt"], sha256_crypt__default_rounds=77123)
>>> myctx.encrypt("fooey")
>>> myctx.hash("fooey")
'$5$rounds=77123$60Y7mpmAhUv6RDvj$AdseAOq6bKUZRDRTr/2QK1t38qm3P6sYeXhXKnBAmg0'
^^^^^
......@@ -211,7 +211,7 @@ in ``schemes``, and :samp:`{option}` one of the parameters below:
Instead of using a fixed rounds value (such as specified by
``default_rounds``, above); this option will cause each call
to :meth:`~CryptContext.encrypt` to vary the default rounds value
to :meth:`~CryptContext.hash` to vary the default rounds value
by some amount.
This can be an integer value, in which case each call will use a rounds
......@@ -223,13 +223,13 @@ in ``schemes``, and :samp:`{option}` one of the parameters below:
As an example of how this parameter operates::
>>> # without vary_rounds set, encrypt() uses the same amount each time:
>>> # without vary_rounds set, hash() uses the same amount each time:
>>> from passlib.context import CryptContext
>>> myctx = CryptContext(schemes=["sha256_crypt"],
... sha256_crypt__default_rounds=80000)
>>> myctx.encrypt("fooey")
>>> myctx.hash("fooey")
'$5$rounds=80000$60Y7mpmAhUv6RDvj$AdseAOq6bKUZRDRTr/2QK1t38qm3P6sYeXhXKnBAmg0'
>>> myctx.encrypt("fooey")
>>> myctx.hash("fooey")
'$5$rounds=80000$60Y7mpmAhUv6RDvj$AdseAOq6bKUZRDRTr/2QK1t38qm3P6sYeXhXKnBAmg0'
^^^^^
......@@ -238,9 +238,9 @@ in ``schemes``, and :samp:`{option}` one of the parameters below:
>>> myctx = CryptContext(schemes=["sha256_crypt"],
... sha256_crypt__default_rounds=80000,
... sha256_crypt__vary_rounds=0.1)
>>> myctx.encrypt("fooey")
>>> myctx.hash("fooey")
'$5$rounds=83966$bMpgQxN2hXo2kVr4$jL4Q3ov41UPgSbO7jYL0PdtsOg5koo4mCa.UEF3zan.'
>>> myctx.encrypt("fooey")
>>> myctx.hash("fooey")
'$5$rounds=72109$43BBHC/hYPHzL69c$VYvVIdKn3Zdnvu0oJHVlo6rr0WjiMTGmlrZrrH.GxnA'
^^^^^
......@@ -333,13 +333,13 @@ For example, a CryptContext could be set up as follows::
>>> # In this case, calling encrypt with ``category=None`` would result
>>> # in a hash that used 77000 sha256-crypt rounds:
>>> myctx.encrypt("password", category=None)
>>> myctx.hash("password", category=None)
'$5$rounds=77000$sj3XI0AbKlEydAKt$BhFvyh4.IoxaUeNlW6rvQ.O0w8BtgLQMYorkCOMzf84'
^^^^^
>>> # But if the application passed in ``category="staff"`` when an administrative
>>> # account set their password, 88000 rounds would be used:
>>> myctx.encrypt("password", category="staff")
>>> myctx.hash("password", category="staff")
'$5$rounds=88000$w7XIdKfTI9.YLwmA$MIzGvs6NU1QOQuuDHhICLmDsdW/t94Bbdfxdh/6NJl7'
^^^^^
......@@ -353,6 +353,7 @@ purpose is to act as a container for multiple password hashes.
Most applications will only need to make use two methods in a CryptContext
instance:
.. automethod:: CryptContext.hash
.. automethod:: CryptContext.encrypt
.. automethod:: CryptContext.verify
.. automethod:: CryptContext.identify
......
......@@ -14,12 +14,12 @@ for new applications. This class can be used directly as follows::
>>> from passlib.hash import bcrypt
>>> # generate new salt, encrypt password
>>> h = bcrypt.encrypt("password")
>>> h = bcrypt.hash("password")
>>> h
'$2a$12$NT0I31Sa7ihGEWpka9ASYrEFkhuTNeBQ2xfZskIiiJeyFXhRgS.Sy'
>>> # the same, but with an explicit number of rounds
>>> bcrypt.encrypt("password", rounds=8)
>>> bcrypt.hash("password", rounds=8)
'$2a$08$8wmNsdCH.M21f.LSBSnYjQrZ9l1EmtBc9uNPGL.9l75YE8D8FlnZC'
>>> # verify password
......
......@@ -16,12 +16,12 @@ This class can be used directly as follows::
>>> from passlib.hash import bcrypt_sha256
>>> # generate new salt, encrypt password
>>> h = bcrypt_sha256.encrypt("password")
>>> h = bcrypt_sha256.hash("password")
>>> h
'$bcrypt-sha256$2a,12$LrmaIX5x4TRtAwEfwJZa1.$2ehnw6LvuIUTM0iz4iz9hTxv21B6KFO'
>>> # the same, but with an explicit number of rounds
>>> bcrypt.encrypt("password", rounds=8)
>>> bcrypt.hash("password", rounds=8)
'$bcrypt-sha256$2a,8$UE3dIZ.0I6XZtA/LdMrrle$Ag04/5zYu./12.OSqInXZnJ.WZoh1ua'
>>> # verify password
......
......@@ -17,12 +17,12 @@ It class can be used directly as follows::
>>> from passlib.hash import bsdi_crypt
>>> # generate new salt, encrypt password
>>> hash = bsdi_crypt.encrypt("password")
>>> hash = bsdi_crypt.hash("password")
>>> hash
'_7C/.Bf/4gZk10RYRs4Y'
>>> # same, but with explict number of rounds
>>> bsdi_crypt.encrypt("password", rounds=10001)
>>> bsdi_crypt.hash("password", rounds=10001)
'_FQ0.amG/zwCMip7DnBk'
>>> # verify password
......
......@@ -34,7 +34,7 @@ newer systems. They can be used directly as follows::
>>> from passlib.hash import cisco_pix as pix
>>> # encrypt password using specified username
>>> hash = pix.encrypt("password", user="user")
>>> hash = pix.hash("password", user="user")
>>> hash
'A5XOy94YKDPXCo7U'
......@@ -49,7 +49,7 @@ newer systems. They can be used directly as follows::
False
>>> # encrypt password without associate user account
>>> hash2 = pix.encrypt("password")
>>> hash2 = pix.hash("password")
>>> hash2
'NuLKvvWGg.x9HEKO'
......
......@@ -23,7 +23,7 @@ This class can be used directly as follows::
>>> from passlib.hash import cisco_type7
>>> # encode password
>>> h = cisco_type7.encrypt("password")
>>> h = cisco_type7.hash("password")
>>> h
'044B0A151C36435C0D'
......
......@@ -17,7 +17,7 @@ It can used directly as follows::
>>> from passlib.hash import des_crypt
>>> # generate new salt, encrypt password
>>> hash = des_crypt.encrypt("password")
>>> hash = des_crypt.hash("password")
'JQMuyS6H.AGMo'
>>> # verify the password
......
......@@ -42,7 +42,7 @@ These classes can be used directly as follows::
>>> from passlib.hash import django_pbkdf2_sha256 as handler
>>> # encrypt password
>>> h = handler.encrypt("password")
>>> h = handler.hash("password")
>>> h
'pbkdf2_sha256$10000$s1w0UXDd00XB$+4ORmyvVWAQvoAEWlDgN34vlaJx1ZTZpa1pCSRey2Yk='
......@@ -122,7 +122,7 @@ These classes can be used directly as follows::
>>> from passlib.hash import django_salted_sha1 as handler
>>> # encrypt password
>>> h = handler.encrypt("password")
>>> h = handler.hash("password")
>>> h
'sha1$c6218$161d1ac8ab38979c5a31cbaba4a67378e7e60845'
......
......@@ -24,12 +24,12 @@ It can be used directly as follows::
>>> from passlib.hash import fshp
>>> # generate new salt, encrypt password
>>> hash = fshp.encrypt("password")
>>> hash = fshp.hash("password")
>>> hash
'{FSHP1|16|16384}PtoqcGUetmVEy/uR8715TNqKa8+teMF9qZO1lA9lJNUm1EQBLPZ+qPRLeEPHqy6C'
>>> # the same, but with an explicit number of rounds, larger salt, and specific variant
>>> fshp.encrypt("password", rounds=40000, salt_size=32, variant="sha512")
>>> fshp.hash("password", rounds=40000, salt_size=32, variant="sha512")
'{FSHP3|32|40000}cB8yE/CuADSgUTQZjWy+YTf/cvbU11D/rHNKiUiB6z4dIaO77U/rmNW
pgZcZllZbCra5GJ8ZfFRNwCHirPqvYTAnbaQQeFQbWym/frRrRev3buoygFQRYexl4091Pc5m'
......
......@@ -57,7 +57,7 @@ The result is then encoded into hexadecimal.
>>> from passlib.hash import pbkdf2_sha512, grub_pbkdf2_sha512
>>> # given a pbkdf2_sha512 hash...
>>> h = pbkdf2_sha512.encrypt("password")
>>> h = pbkdf2_sha512.hash("password")
>>> h
'$pbkdf2-sha512$6400$y6vYff3SihJiqumIrNXwGw$NobVwyUlVI52/Cvrguwli5fX6XgKHNUf7fWWS2VgoWEevaTCiZx4OCYhwGFwzUAuz/g1zQVSIf.9JEb0BEVEEA'
......
......@@ -23,7 +23,7 @@ and can be used directly as follows::
>>> from passlib.hash import hex_sha1 as hex_sha1
>>> # encrypt password
>>> h = hex_sha1.encrypt("password")
>>> h = hex_sha1.hash("password")
>>> h
'5baa61e4c9b93f3f0682250b6cf8331b7ee68fd8'
......
......@@ -21,7 +21,7 @@ elsewhere in Passlib, and can be used directly as follows::
>>> from passlib.hash import ldap_md5_crypt
>>> # encrypt password
>>> hash = ldap_md5_crypt.encrypt("password")
>>> hash = ldap_md5_crypt.hash("password")
>>> hash
'{CRYPT}$1$gwvn5BO0$3dyk8j.UTcsNUPrLMsU6/0'
......
......@@ -15,7 +15,7 @@ and are can be used directly as follows::
>>> from passlib.hash import ldap_salted_md5 as lsm
>>> # encrypt password
>>> hash = lsm.encrypt("password")
>>> hash = lsm.hash("password")
>>> hash
'{SMD5}OqsUXNHIhHbznxrqHoIM+ZT8DmE='
......
......@@ -25,7 +25,7 @@ This class can be used directly as follows::
>>> from passlib.hash import lmhash
>>> # encrypt password
>>> h = lmhash.encrypt("password")
>>> h = lmhash.hash("password")
>>> h
'e52cac67419a9a224a3b108f3fa6cb6d'
......@@ -124,7 +124,7 @@ the handling of non-ASCII characters.
Thus if an application wishes to provide support for non-ASCII passwords,
it must decide which encoding to use. Passlib uses ``cp437`` as a
default, but this may need to be overridden via
``lmhash.encrypt(secret, encoding="some-other-codec")``.
``lmhash.hash(secret, encoding="some-other-codec")``.
All known encodings are ``us-ascii``-compatible, so for ASCII passwords,
the default should be sufficient.
......
......@@ -32,7 +32,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
>>> h = md5_crypt.encrypt("password")
>>> h = md5_crypt.hash("password")
>>> h
'$1$3azHgidD$SrJPt7B.9rekpmwJwtON31'
......@@ -43,7 +43,7 @@ The :class:`!md5_crypt` class can be can be used directly as follows::
False
>>> # encrypt password using cisco-compatible 4-char salt
>>> md5_crypt.encrypt("password", salt_size=4)
>>> md5_crypt.hash("password", salt_size=4)
'$1$wu98$9UuD3hvrwehnqyF1D548N0'
.. seealso::
......
......@@ -28,7 +28,7 @@ This class can be used directly as follows::
>>> from passlib.hash import msdcc
>>> # encrypt password using specified username
>>> hash = msdcc.encrypt("password", user="Administrator")
>>> hash = msdcc.hash("password", user="Administrator")
>>> hash
'25fd08fa89795ed54207e6e8442a6ca0'
......
......@@ -22,7 +22,7 @@ This class can be used directly as follows::
>>> from passlib.hash import msdcc2
>>> # encrypt password using specified username
>>> hash = msdcc2.encrypt("password", user="Administrator")
>>> hash = msdcc2.hash("password", user="Administrator")
>>> hash
'4c253e4b65c007a8cd683ea57bc43c76'
......
......@@ -20,7 +20,7 @@ This class can be used directly as follows::
>>> from passlib.hash import mssql2000 as m20
>>> # encrypt password
>>> h = m20.encrypt("password")
>>> h = m20.hash("password")
>>> h
'0x0100200420C4988140FD3920894C3EDC188E94F428D57DAD5905F6CC1CBAF950CAD4C63F272B2C91E4DEEB5E6444'
......
......@@ -19,7 +19,7 @@ This class can be used directly as follows::
>>> from passlib.hash import mssql2005 as m25