def sha384(string, salt=None, front=False, back=False, **placeholder):
"""
Create an SHA384 hash from a given string
> :param string:
> :return:
Example:
>>> sha384("test")
768412320f7b0aa5812fce428dc4706b3cae50e02a64caa16a782249bfe8efc4b7ef1ccb126255d196047dfedf17a0a9
"""
if type(string) is unicode:
string = lib.settings.force_encoding(string)
if type(string) is unicode:
string = lib.settings.force_encoding(string)
obj = hashlib.sha384()
if salt is not None and front and not back:
obj.update(salt + string)
elif salt is not None and back and not front:
obj.update(string + salt)
else:
obj.update(string)
return obj.hexdigest()
评论列表
文章目录