summaryrefslogtreecommitdiff
path: root/passlib/ext
diff options
context:
space:
mode:
authorEli Collins <elic@assurancetechnologies.com>2016-06-10 12:32:52 -0400
committerEli Collins <elic@assurancetechnologies.com>2016-06-10 12:32:52 -0400
commit281dacd121d72c7570442a13f2113f63c6c439ba (patch)
tree997fcabde572da2fc5c8158243e26cce64ee3874 /passlib/ext
parent61dc39910c6904c69f2e81d5dd41090cac1f18a1 (diff)
downloadpasslib-281dacd121d72c7570442a13f2113f63c6c439ba.tar.gz
.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().
Diffstat (limited to 'passlib/ext')
-rw-r--r--passlib/ext/django/models.py4
-rw-r--r--passlib/ext/django/utils.py22
2 files changed, 8 insertions, 18 deletions
diff --git a/passlib/ext/django/models.py b/passlib/ext/django/models.py
index 0349012..1337ce2 100644
--- a/passlib/ext/django/models.py
+++ b/passlib/ext/django/models.py
@@ -84,7 +84,7 @@ def _apply_patch():
else:
# NOTE: pulls _get_category from module globals
cat = _get_category(user)
- user.password = password_context.encrypt(password, category=cat)
+ user.password = password_context.hash(password, category=cat)
@_manager.monkeypatch(USER_PATH)
def check_password(user, password):
@@ -154,7 +154,7 @@ def _apply_patch():
# Django make_password() autogenerates a salt if salt is bool False (None / ''),
# so we only pass the keyword on if there's actually a fixed salt.
kwds['salt'] = salt
- return password_context.encrypt(password, **kwds)
+ return password_context.hash(password, **kwds)
@_manager.monkeypatch(HASHERS_PATH)
@lru_cache.lru_cache()
diff --git a/passlib/ext/django/utils.py b/passlib/ext/django/utils.py
index 07a11db..b20da79 100644
--- a/passlib/ext/django/utils.py
+++ b/passlib/ext/django/utils.py
@@ -247,7 +247,7 @@ class _PasslibHasherWrapper(object):
# hasher api
#=====================================================================
def salt(self):
- # NOTE: passlib's handler.encrypt() should generate new salt each time,
+ # NOTE: passlib's handler.hash() should generate new salt each time,
# so this just returns a special constant which tells
# encode() (below) not to pass a salt keyword along.
return _GEN_SALT_SIGNAL
@@ -267,8 +267,8 @@ class _PasslibHasherWrapper(object):
else:
kwds['rounds'] = self.rounds
elif rounds is not None or iterations is not None:
- warn("%s.encrypt(): 'rounds' and 'iterations' are ignored" % self.__name__)
- return self.passlib_handler.encrypt(password, **kwds)
+ warn("%s.hash(): 'rounds' and 'iterations' are ignored" % self.__name__)
+ return self.passlib_handler.hash(password, **kwds)
def safe_summary(self, encoded):
from django.contrib.auth.hashers import mask_hash
@@ -422,19 +422,9 @@ def _get_hasher(algorithm):
## return to_unicode(hash, "latin-1", "hash").startswith(self.ident)
##
## @property
-## def genconfig(self):
-## # XXX: not sure how to support this.
-## return None
-##
-## @property
-## def genhash(self, secret, config):
-## if config is not None:
-## # XXX: not sure how to support this.
-## raise NotImplementedError("genhash() for hashers not implemented")
-## return self.encrypt(secret)
-##
-## @property
-## def encrypt(self, secret, salt=None, **kwds):
+## def hash(self, secret, config=None, salt=None, **kwds):
+## if config:
+## raise NotImplementedError('hash(config) support missing')
## # NOTE: from how make_password() is coded, all hashers
## # should have salt param. but only some will have
## # 'iterations' parameter.