예제 #1
0
def base58_check_encode(prefix, payload, compressed=False):
    s = prefix + payload
    if compressed:
        s = prefix + payload + b'\x01'
    checksum = hashlib.sha256(hashlib.sha256(s).digest()).digest()[0:4]
    result = s + checksum
    return '1' * count_leading_zeroes(result) + b58encode(result).decode()
def base58_check_encode(prefix, payload, compressed=False):
    # Add version byte in front of RIPEMD-160 hash (0x00 for Main Network)
    s = prefix + payload
    if compressed:
        s = prefix + payload + b'\x01'

    # Add the 4 checksum bytes at the end of extended RIPEMD-160 hash. This is the 25-byte binary Bitcoin Address.
    checksum = hashlib.sha256(hashlib.sha256(s).digest()).digest()[0:4]
    result = s + checksum
    return '1' * count_leading_zeroes(result) + b58encode(result).decode()
def generate_test_file():
    filename="test.dat"
    uuid=b58encode(os.urandom(16))
    file_dir = create_file_directories(uuid)
    file_path = file_dir+"/"+filename
    file_size=1024
    fh = open(file_path, 'w')
    while os.path.getsize(file_path) <= file_size:
        fh.write(os.urandom(16))
    fh.close()
    sha256_hash = hashfile(file_path)
    f=File.objects.create(uuid=uuid, name=filename, file_sha256=sha256_hash)
    f.save()
    set_setting("test_file", str(f.id))
    pass
예제 #4
0
#!/usr/bin/env python3

import utils
import base58


string = bytes('λ¬Έν˜„μˆ˜', encoding = 'utf-8')
string = b'\x00\x00\x01' + string + b'\x00\x00\x01'

print(utils.b58encode(string))
print(base58.b58encode(string))