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

[mod] #176: Use base58 module

Not added as a direct dependency, since it is a DuniterPy dependency
And Silkaj won't get away from DuniterPy, nor DuniterPy will stop using
base58.
parent 1f20724d
No related branches found
No related tags found
1 merge request!149#176: Get rid of PyNaCl and use base58 module
...@@ -17,6 +17,8 @@ along with Silkaj. If not, see <https://www.gnu.org/licenses/>. ...@@ -17,6 +17,8 @@ along with Silkaj. If not, see <https://www.gnu.org/licenses/>.
import re import re
import hashlib import hashlib
import base58
from nacl import encoding from nacl import encoding
from silkaj.constants import PUBKEY_PATTERN from silkaj.constants import PUBKEY_PATTERN
...@@ -77,9 +79,9 @@ def gen_checksum(pubkey): ...@@ -77,9 +79,9 @@ 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 = base58.b58decode(pubkey)
hash = hashlib.sha256(hashlib.sha256(pubkey_byte).digest()).digest() hash = hashlib.sha256(hashlib.sha256(pubkey_byte).digest()).digest()
return b58_encode(hash)[:3] return base58.b58encode(hash)[:3].decode("utf-8")
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