Hashlib doesn't take unicode.

This commit is contained in:
Anthony Sottile
2014-06-18 07:36:11 -07:00
parent a34f3fc7c9
commit 5d1ffcba75
3 changed files with 14 additions and 11 deletions

View File

@@ -2,6 +2,7 @@ from __future__ import unicode_literals
import contextlib
import functools
import hashlib
import os
import os.path
import shutil
@@ -56,3 +57,11 @@ def noop_context():
def shell_escape(arg):
return "'" + arg.replace("'", "'\"'\"'".strip()) + "'"
def hex_md5(s):
"""Hexdigest an md5 of the string.
:param text s:
"""
return hashlib.md5(s.encode('utf-8')).hexdigest()