mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-12-18 08:02:49 +01:00
Encode strings before hashing them in utils.file.mktemp.
This commit is contained in:
parent
54917f581a
commit
174a5a4b1f
@ -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:
|
||||||
|
Loading…
Reference in New Issue
Block a user