added 'ascii' to str.encode() calls to support porting to other langs

This commit is contained in:
Kjistóf 2017-12-02 17:18:12 +01:00
parent ee5b0c08c5
commit 027b1e20fb

View File

@ -26,7 +26,7 @@ class pow_base:
raise RuntimeError('Failed to find a nonce in {} iterations!'.format(max_attempts))
def verify(self, nonce):
hexresult = self._hexdigest(self._base + str(nonce).encode())
hexresult = self._hexdigest(self._base + str(nonce).encode('ascii'))
return int(hexresult, 16) < self._target
def export(self):
@ -35,7 +35,7 @@ class pow_base:
@classmethod
def load(cls, export):
difficulty, base = export.split(':', 1)
return cls(int(difficulty), b64decode(base.encode()))
return cls(int(difficulty), b64decode(base.encode('ascii')))
class pow_hashlib_base(pow_base):