Skip to content
Snippets Groups Projects
Commit 1f20724d authored by Moul's avatar Moul
Browse files

[mod] #176: Use sha256 from hashlib from stdlib

parent 6a9bc455
No related branches found
No related tags found
1 merge request!149#176: Get rid of PyNaCl and use base58 module
...@@ -16,7 +16,8 @@ along with Silkaj. If not, see <https://www.gnu.org/licenses/>. ...@@ -16,7 +16,8 @@ along with Silkaj. If not, see <https://www.gnu.org/licenses/>.
""" """
import re import re
from nacl import encoding, hash import hashlib
from nacl import encoding
from silkaj.constants import PUBKEY_PATTERN from silkaj.constants import PUBKEY_PATTERN
from silkaj.tools import message_exit from silkaj.tools import message_exit
...@@ -77,9 +78,8 @@ def gen_checksum(pubkey): ...@@ -77,9 +78,8 @@ def gen_checksum(pubkey):
Returns the checksum of the input pubkey (encoded in b58) Returns the checksum of the input pubkey (encoded in b58)
""" """
pubkey_byte = b58_decode(pubkey) pubkey_byte = b58_decode(pubkey)
return b58_encode( hash = hashlib.sha256(hashlib.sha256(pubkey_byte).digest()).digest()
hash.sha256(hash.sha256(pubkey_byte, encoding.RawEncoder), encoding.RawEncoder) return b58_encode(hash)[:3]
)[:3]
b58_digits = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz" b58_digits = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment