b3fde9d78d
* Replaces `six` urllib with python 3's urllib * Replaces `six`'s int2byte method with native `bytes` class * Removes edge case testing for python2 vs python3 * Removes useless object inheritance * Uses native io.BytesIO instead of six.BytesIO * Removes six from dependencies
23 lines
381 B
Python
23 lines
381 B
Python
import hashlib
|
|
|
|
|
|
def sha256(x):
|
|
if isinstance(x, str):
|
|
x = x.encode('utf-8')
|
|
return hashlib.sha256(x).digest()
|
|
|
|
|
|
def double_sha256(x):
|
|
return sha256(sha256(x))
|
|
|
|
|
|
def ripemd160(x):
|
|
if isinstance(x, str):
|
|
x = x.encode('utf-8')
|
|
md = hashlib.new('ripemd160')
|
|
md.update(x)
|
|
return md.digest()
|
|
|
|
|
|
def hash160(x):
|
|
return ripemd160(sha256(x))
|