我们从Python开源项目中,提取了以下8个代码示例,用于说明如何使用django.contrib.auth.hashers.mask_hash()。
def safe_summary(self, encoded): from django.contrib.auth.hashers import mask_hash, _, SortedDict handler = self.passlib_handler items = [ # since this is user-facing, we're reporting passlib's name, # without the distracting PASSLIB_HASHER_PREFIX prepended. (_('algorithm'), handler.name), ] if hasattr(handler, "parsehash"): kwds = handler.parsehash(encoded, sanitize=mask_hash) for key, value in iteritems(kwds): key = self._translate_kwds.get(key, key) items.append((_(key), value)) return SortedDict(items) # added in django 1.6
def safe_summary(self, encoded): from django.contrib.auth.hashers import mask_hash from django.utils.translation import ugettext_noop as _ from django.utils.datastructures import SortedDict handler = self.passlib_handler items = [ # since this is user-facing, we're reporting passlib's name, # without the distracting PASSLIB_HASHER_PREFIX prepended. (_('algorithm'), handler.name), ] if hasattr(handler, "parsehash"): kwds = handler.parsehash(encoded, sanitize=mask_hash) for key, value in iteritems(kwds): key = self._translate_kwds.get(key, key) items.append((_(key), value)) return SortedDict(items) # added in django 1.6
def safe_summary(self, encoded): from django.contrib.auth.hashers import mask_hash from django.utils.translation import ugettext_noop as _ handler = self.passlib_handler items = [ # since this is user-facing, we're reporting passlib's name, # without the distracting PASSLIB_HASHER_PREFIX prepended. (_('algorithm'), handler.name), ] if hasattr(handler, "parsehash"): kwds = handler.parsehash(encoded, sanitize=mask_hash) for key, value in iteritems(kwds): key = self._translate_kwds.get(key, key) items.append((_(key), value)) return OrderedDict(items)
def safe_summary(self, encoded): algorithm, prefix, salt, hash = encoded.split('$') assert algorithm == self.algorithm return OrderedDict([ (_('algorithm'), algorithm), (_('prefix'), prefix), (_('salt'), mask_hash(salt)), (_('hash'), mask_hash(hash)), ])
def safe_summary(self, encoded: str) -> Dict[str, str]: """ Returns a summary of safe values The result is a dictionary and will be used where the password field must be displayed to construct a safe representation of the password. """ roundcount, salt, hash = self._split_encoded(encoded) return OrderedDict([ (_('algorithm'), self.algorithm), (_('iterations'), str(roundcount)), (_('salt'), hashers.mask_hash(salt)), (_('hash'), hashers.mask_hash(hash)), ])