Encode strings before hashing them in utils.file.mktemp.

This commit is contained in:
Valentin Lorentz 2012-08-04 16:39:33 +02:00
parent 54917f581a
commit 174a5a4b1f
1 changed files with 2 additions and 2 deletions

View File

@ -83,7 +83,7 @@ def touch(filename):
def mktemp(suffix=''): def mktemp(suffix=''):
"""Gives a decent random string, suitable for a filename.""" """Gives a decent random string, suitable for a filename."""
r = random.Random() r = random.Random()
m = crypt.md5(suffix) m = crypt.md5(suffix.encode('utf8'))
r.seed(time.time()) r.seed(time.time())
s = str(r.getstate()) s = str(r.getstate())
period = random.random() period = random.random()
@ -95,7 +95,7 @@ def mktemp(suffix=''):
m.update(s) m.update(s)
m.update(str(now)) m.update(str(now))
s = m.hexdigest() s = m.hexdigest()
return crypt.sha(s + str(time.time())).hexdigest() + suffix return crypt.sha((s + str(time.time())).encode('utf8')).hexdigest()+suffix
def nonCommentLines(fd): def nonCommentLines(fd):
for line in fd: for line in fd: