diff mbox series

[1/1] make random seed function python3 compatible

Message ID 20201025105605.5692-2-jeremy.006@gmail.com
State New
Headers show
Series pysim: make random seed function python3 compatible | expand

Commit Message

Jeremy Herbert Oct. 25, 2020, 10:56 a.m. UTC
---
 pySim-prog.py | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/pySim-prog.py b/pySim-prog.py
index 942cfb0..e172d80 100755
--- a/pySim-prog.py
+++ b/pySim-prog.py
@@ -225,8 +225,9 @@  def parse_options():
 
 
 def _digits(secret, usage, len, num):
-	s = hashlib.sha1(secret + usage + '%d' % num)
-	d = ''.join(['%02d'%ord(x) for x in s.digest()])
+	seed = secret + usage + '%d' % num
+	s = hashlib.sha1(seed.encode())
+	d = ''.join(['%02d' % x for x in s.digest()])
 	return d[0:len]
 
 def _mcc_mnc_digits(mcc, mnc):