From 59f6f02ae7f0eb550d7d035006963f7962a270ff Mon Sep 17 00:00:00 2001 From: Lucas Oliveira Date: Mon, 30 Oct 2023 23:02:04 -0300 Subject: [PATCH] fix(deprecated): lib pysha3 has reached its end of life is no longer supported https://github.com/tiran/pysha3, change to pycryptodome --- merkly/utils.py | 8 ++++++-- pyproject.toml | 6 +++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/merkly/utils.py b/merkly/utils.py index 4506e01..7beee1d 100644 --- a/merkly/utils.py +++ b/merkly/utils.py @@ -3,7 +3,7 @@ """ from typing import Callable, List, Tuple -from sha3 import keccak_256 +from Crypto.Hash import keccak as cryptodome_keccak import types @@ -43,7 +43,11 @@ def keccak(data: str) -> str: "541111248b45b7a8dc3f5579f630e74cb01456ea6ac067d3f4d793245a255155" ``` """ - return keccak_256(data.encode()).hexdigest() + + keccak_256 = cryptodome_keccak.new(digest_bits=256) + keccak_256.update(data.encode()) + + return keccak_256.hexdigest() def half(list_item: List[int]) -> Tuple[int, int]: diff --git a/pyproject.toml b/pyproject.toml index 3a5719d..b7e9649 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -16,14 +16,14 @@ keywords = [ ] [tool.poetry.dependencies] - python = "^3.8" - pysha3 = "^1.0.2" + pycryptodome = "^3.19.0" pydantic = "^1.10.2" - coverage = "^7.2.7" + python = "^3.8" [tool.poetry.dev-dependencies] conventional-pre-commit = "^2.1.1" pre-commit = "^3.0.3" + coverage = "^7.2.7" pyclean = "^2.2.0" pytest = "^7.2.1" black = "^23.1.0"