Author: Martin Matusiak <numero...@gmail.com> Branch: py3.3-fixes3 Changeset: r72860:27a13b5357da Date: 2014-08-17 19:49 +0200 http://bitbucket.org/pypy/pypy/changeset/27a13b5357da/
Log: port _sha256.py to py3 diff --git a/lib_pypy/_sha256.py b/lib_pypy/_sha256.py --- a/lib_pypy/_sha256.py +++ b/lib_pypy/_sha256.py @@ -201,7 +201,7 @@ dig = [] for i in sha_info['digest']: dig.extend([ ((i>>24) & 0xff), ((i>>16) & 0xff), ((i>>8) & 0xff), (i & 0xff) ]) - return ''.join([chr(i) for i in dig]) + return bytes(dig) class sha256(object): digest_size = digestsize = SHA_DIGESTSIZE @@ -219,7 +219,7 @@ return sha_final(self._sha.copy())[:self._sha['digestsize']] def hexdigest(self): - return ''.join(['%.2x' % ord(i) for i in self.digest()]) + return ''.join(['%.2x' % i for i in self.digest()]) def copy(self): new = sha256.__new__(sha256) @@ -240,7 +240,7 @@ return new def test(): - a_str = "just a test string" + a_str = b"just a test string" assert 'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855' == sha256().hexdigest() assert 'd7b553c6f09ac85d142415f857c5310f3bbbe7cdd787cce4b985acedd585266f' == sha256(a_str).hexdigest() _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit