def do_encrypt(self, secret, use_encrypt=False, handler=None, context=None, **settings):
"""call handler's hash() method with specified options"""
self.populate_settings(settings)
if context is None:
context = {}
secret = self.populate_context(secret, context)
if use_encrypt:
# use legacy 1.6 api
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)
评论列表
文章目录