parent
ed39c2001e
commit
0d8112f6b4
@ -1,4 +0,0 @@
|
||||
from TrezorCrypto import Base58, Sha256
|
||||
|
||||
base58 = Base58()
|
||||
sha256 = Sha256()
|
@ -0,0 +1,21 @@
|
||||
from TrezorCrypto import Base58
|
||||
from . import sha256
|
||||
|
||||
_base58 = Base58()
|
||||
|
||||
def encode(data):
|
||||
return _base58.encode(data)
|
||||
|
||||
def decode(string):
|
||||
return _base58.decode(string)
|
||||
|
||||
def encode_check(data, hashlen=4):
|
||||
h = sha256.hash(data)
|
||||
return encode(data + h[:hashlen])
|
||||
|
||||
def decode_check(string, hashlen=4):
|
||||
data = decode(string)
|
||||
d, h = data[:-hashlen], data[-hashlen:]
|
||||
if sha256.hash(d) != h:
|
||||
raise RuntimeError('Checksum error')
|
||||
return d
|
@ -0,0 +1,6 @@
|
||||
from TrezorCrypto import Sha256
|
||||
|
||||
_sha256 = Sha256()
|
||||
|
||||
def hash(data):
|
||||
return _sha256.hash(data)
|
Loading…
Reference in new issue