예제 #1
0
def bin_hash160(string):
    intermed = hashlib.sha256(string).digest()
    digest = ''
    if not hasattr(hashlib, 'ripemd160'):
        hashlib.ripemd160 = RIPEMD160
    digest = hashlib.ripemd160(intermed).digest()
    return digest
예제 #2
0
def bin_hash160(string):
    intermed = hashlib.sha256(string).digest()
    digest = ''
    if not hasattr(hashlib, 'ripemd160'):
        hashlib.ripemd160 = RIPEMD160
    digest = hashlib.ripemd160(intermed).digest()
    return digest
예제 #3
0
def bin_hash160(string):
    intermed = hashlib.sha256(string).digest()
    digest = ''
    if not hasattr(hashlib, 'ripemd160') or \
     "ripemd160" not in (hashlib.algorithms if is_python2 else hashlib.algorithms_available):
        hashlib.ripemd160 = RIPEMD160
    digest = hashlib.ripemd160(intermed).digest()
    return digest
예제 #4
0
def bin_hash160(string):
    intermed = hashlib.sha256(string).digest()
    digest = ''
    if not hasattr(hashlib, 'ripemd160') or \
     "ripemd160" not in (hashlib.algorithms if is_python2 else hashlib.algorithms_available):
        hashlib.ripemd160 = RIPEMD160
    digest = hashlib.ripemd160(intermed).digest()
    return digest
예제 #5
0
def ripemd_160(text):
    """hash the content of text
       text : String or list of String
    """
    h = ripemd160('ripemd160')
    if type(text) == str:
        h.update(text.encode('utf-8'))
    else:  #type(text) == list
        for i in text:
            h.update(i.encode('utf-8'))
    return h.hexdigest()
예제 #6
0
def digitally_sign(source, secret, hasher="md5"):
    """
    >>> digitally_sign("Supercalifragilisticexpialidocious", 'pop song')
    ('Supercalifragilisticexpialidocious44bf69fb4ac3af50432043ab0f69aaaf', 16)
    """
    hasher = hasher.lower()
    if hasher == "sha512":
        secured = hashlib.sha512()
    elif hasher == "sha384":
        secured = hashlib.sha384()
    elif hasher == "sha256":
        secured = hashlib.sha256()
    elif hasher == "sha224":
        secured = hashlib.sha224()
    elif hasher == "sha1":
        secured = hashlib.sha1()
    elif hasher == "ripemd160":
        secured = hashlib.ripemd160()
    else:
        secured = hashlib.md5()

    secured.update(source.encode('utf-8') + secret.encode('utf-8'))
    digest = secured.hexdigest()
    return source + digest, secured.digest_size
예제 #7
0
def hash160(msg):
    """ripemd160(sha256(msg)) -> bytes"""
    return hashlib.ripemd160(hashlib.sha256(msg).digest()).digest()
예제 #8
0
def bin_ripemd160(string):
    if not hasattr(hashlib, 'ripemd160'):
        hashlib.ripemd160 = RIPEMD160
    digest = hashlib.ripemd160(string).digest()
    return digest
예제 #9
0
	def deriveAddress(publicKey):
		bytes = hexToBytes(publicKey)
		hash256 = hashlib.sha256().update(bytes).digest()
		input = Buffer(hashlib.ripemd160().update(hash256).digest())
		return __encode(ACCOUNT_PREFIX, input)
예제 #10
0
def bin_ripemd160(string):
    if not hasattr(hashlib, 'ripemd160') or "ripemd160" not in hashlib.algorithms:
        hashlib.ripemd160 = RIPEMD160
    digest = hashlib.ripemd160(string).digest()
    return digest
예제 #11
0
def bin_ripemd160(string):
    if not hasattr(hashlib, 'ripemd160') or \
     "ripemd160" not in (hashlib.algorithms if is_python2 else hashlib.algorithms_available):
        hashlib.ripemd160 = RIPEMD160
    digest = hashlib.ripemd160(string).digest()
    return digest
예제 #12
0
def bin_ripemd160(string):
    if not hasattr(hashlib, 'ripemd160'):
        hashlib.ripemd160 = RIPEMD160
    digest = hashlib.ripemd160(string).digest()
    return digest
예제 #13
0
def bin_ripemd160(string):
    if not hasattr(hashlib, 'ripemd160') or \
     "ripemd160" not in (hashlib.algorithms if is_python2 else hashlib.algorithms_available):
        hashlib.ripemd160 = RIPEMD160
    digest = hashlib.ripemd160(string).digest()
    return digest
예제 #14
0
 def getHashedAddress(self, publicKey):
     return hashlib.ripemd160(hashlib.sha256(publicKey))
예제 #15
0
def ripemd160(msg):
    """one-line rmd160(msg) -> bytes"""
    return hashlib.ripemd160(msg).digest()
예제 #16
0
def bin_ripemd160(string):
    if not hasattr(hashlib,
                   'ripemd160') or "ripemd160" not in hashlib.algorithms:
        hashlib.ripemd160 = RIPEMD160
    digest = hashlib.ripemd160(string).digest()
    return digest
예제 #17
0
def hash160(s):
    return hashlib.ripemd160(hashlib.sha256(s).digest()).digest()
예제 #18
0
파일: hashes.py 프로젝트: flh4/Python
def ripemd160(s):
    h = hashlib.ripemd160(s.encode())
    return h.hexdigest()