2018-09-17 22:13:30 +02:00
|
|
|
import hashlib
|
|
|
|
|
|
|
|
|
|
|
|
def sha256(x):
|
2018-11-23 05:24:21 +01:00
|
|
|
if isinstance(x, str):
|
2018-09-17 22:13:30 +02:00
|
|
|
x = x.encode('utf-8')
|
|
|
|
return hashlib.sha256(x).digest()
|
|
|
|
|
|
|
|
|
|
|
|
def double_sha256(x):
|
|
|
|
return sha256(sha256(x))
|
|
|
|
|
|
|
|
|
|
|
|
def ripemd160(x):
|
2018-11-23 05:24:21 +01:00
|
|
|
if isinstance(x, str):
|
2018-09-17 22:13:30 +02:00
|
|
|
x = x.encode('utf-8')
|
|
|
|
md = hashlib.new('ripemd160')
|
|
|
|
md.update(x)
|
|
|
|
return md.digest()
|
|
|
|
|
|
|
|
|
|
|
|
def hash160(x):
|
|
|
|
return ripemd160(sha256(x))
|