From 1f20724de117e82b399154d0ce9f0beb09c96c46 Mon Sep 17 00:00:00 2001 From: Moul <moul@moul.re> Date: Sat, 17 Oct 2020 12:03:52 +0200 Subject: [PATCH] [mod] #176: Use sha256 from hashlib from stdlib --- silkaj/crypto_tools.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/silkaj/crypto_tools.py b/silkaj/crypto_tools.py index 0ec8126a..13e9b126 100644 --- a/silkaj/crypto_tools.py +++ b/silkaj/crypto_tools.py @@ -16,7 +16,8 @@ along with Silkaj. If not, see <https://www.gnu.org/licenses/>. """ import re -from nacl import encoding, hash +import hashlib +from nacl import encoding from silkaj.constants import PUBKEY_PATTERN from silkaj.tools import message_exit @@ -77,9 +78,8 @@ def gen_checksum(pubkey): Returns the checksum of the input pubkey (encoded in b58) """ pubkey_byte = b58_decode(pubkey) - return b58_encode( - hash.sha256(hash.sha256(pubkey_byte, encoding.RawEncoder), encoding.RawEncoder) - )[:3] + hash = hashlib.sha256(hashlib.sha256(pubkey_byte).digest()).digest() + return b58_encode(hash)[:3] b58_digits = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz" -- GitLab