From 794d2101e9b5ce4d1efd3d94b8dacfa508145382 Mon Sep 17 00:00:00 2001 From: Jonathan de Jong Date: Tue, 17 Dec 2019 11:00:45 +0100 Subject: [PATCH] fixes #197 --- libp2p/peer/id.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libp2p/peer/id.py b/libp2p/peer/id.py index ab20ed04..9870011b 100644 --- a/libp2p/peer/id.py +++ b/libp2p/peer/id.py @@ -44,7 +44,7 @@ class ID: @property def xor_id(self) -> int: if not self._xor_id: - self._xor_id = int(digest(self._bytes).hex(), 16) + self._xor_id = int(sha256_digest(self._bytes).hex(), 16) return self._xor_id def to_bytes(self) -> bytes: @@ -89,7 +89,7 @@ class ID: return cls(mh_digest.encode()) -def digest(data: Union[str, bytes]) -> bytes: +def sha256_digest(data: Union[str, bytes]) -> bytes: if isinstance(data, str): data = data.encode("utf8") - return hashlib.sha1(data).digest() + return hashlib.sha256(data).digest()