當前位置: 首頁>>代碼示例>>Python>>正文


Python pyblake2.blake2b方法代碼示例

本文整理匯總了Python中pyblake2.blake2b方法的典型用法代碼示例。如果您正苦於以下問題:Python pyblake2.blake2b方法的具體用法?Python pyblake2.blake2b怎麽用?Python pyblake2.blake2b使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在pyblake2的用法示例。


在下文中一共展示了pyblake2.blake2b方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: keypair_from_seed

# 需要導入模塊: import pyblake2 [as 別名]
# 或者: from pyblake2 import blake2b [as 別名]
def keypair_from_seed(seed, index=0):
    """
    Generates a deterministic keypair from `seed` based on `index`

    :param seed: bytes value of seed
    :type seed: bytes

    :param index: offset from seed
    :type index: int

    :return: dict of the form: {
        'private': private_key
        'public': public_key
    }
    """

    h = blake2b(digest_size=32)
    h.update(seed + struct.pack(">L", index))
    priv_key = h.digest()
    pub_key = private_to_public_key(priv_key)
    return {'private': priv_key, 'public': pub_key} 
開發者ID:dourvaris,項目名稱:nano-python,代碼行數:23,代碼來源:crypto.py

示例2: bf

# 需要導入模塊: import pyblake2 [as 別名]
# 或者: from pyblake2 import blake2b [as 別名]
def bf(h, dictionary):

    f = open(dictionary, 'r')
    lines = f.readlines()
    lines = lines.replace('\n', '')
    print('\033[1;34m[*]\033[0m Starting Brute Force - hash = ' + h)
    for i in lines:
    
        m = pyblake2.blake2b()
        m.update(i)
        h2 = m.hexdigest()
    
        if h == h2:
    
            print('\033[1;32m[+]\033[0m Hash Cracked! - Password = ' + i)
            exit()
    print('\033[1;31m[-]\033[0m Hash could not be cracked!') 
開發者ID:lockedbyte,項目名稱:cryptovenom,代碼行數:19,代碼來源:bruteforce.py

示例3: blake

# 需要導入模塊: import pyblake2 [as 別名]
# 或者: from pyblake2 import blake2b [as 別名]
def blake(x):
    return blake2b(x).digest()[:32] 
開發者ID:ethereum,項目名稱:beacon_chain,代碼行數:4,代碼來源:blake.py

示例4: address_checksum

# 需要導入模塊: import pyblake2 [as 別名]
# 或者: from pyblake2 import blake2b [as 別名]
def address_checksum(address):
    """
    Returns the checksum in bytes for an address in bytes
    """
    address_bytes = address
    h = blake2b(digest_size=5)
    h.update(address_bytes)
    checksum = bytearray(h.digest())
    checksum.reverse()
    return checksum 
開發者ID:dourvaris,項目名稱:nano-python,代碼行數:12,代碼來源:crypto.py

示例5: H

# 需要導入模塊: import pyblake2 [as 別名]
# 或者: from pyblake2 import blake2b [as 別名]
def H(m):
    return bytearray(blake2b(m).digest()) 
開發者ID:dourvaris,項目名稱:nano-python,代碼行數:4,代碼來源:ed25519_blake2.py

示例6: hashChain

# 需要導入模塊: import pyblake2 [as 別名]
# 或者: from pyblake2 import blake2b [as 別名]
def hashChain(s):
    a=pyblake2.blake2b(s, digest_size=32).digest()
    b=keccak256.digest(a)
    return b 
開發者ID:PyWaves,項目名稱:PyWaves,代碼行數:6,代碼來源:crypto.py

示例7: blake2b_32

# 需要導入模塊: import pyblake2 [as 別名]
# 或者: from pyblake2 import blake2b [as 別名]
def blake2b_32(v=b''):
    return blake2b(scrub_input(v), digest_size=32) 
開發者ID:murbard,項目名稱:pytezos,代碼行數:4,代碼來源:crypto.py

示例8: public_key_hash

# 需要導入模塊: import pyblake2 [as 別名]
# 或者: from pyblake2 import blake2b [as 別名]
def public_key_hash(self):
        """
        Public key hash for this key.
        :return: the public key hash for this key
        """
        pkh = blake2b(data=self._public_key, digest_size=20).digest()
        prefix = {b'ed': b'tz1', b'sp': b'tz2', b'p2': b'tz3'}[self.curve]
        return base58_encode(pkh, prefix).decode() 
開發者ID:murbard,項目名稱:pytezos,代碼行數:10,代碼來源:crypto.py

示例9: sign

# 需要導入模塊: import pyblake2 [as 別名]
# 或者: from pyblake2 import blake2b [as 別名]
def sign(self, handle, test_mode=False):
        # This code acquires a mutex lock using https://github.com/chiradeep/dyndb-mutex
        # generate a unique name for this process/thread
        ddb_region = environ['REGION']
        payload_chainid = self.get_chain_id()
        my_name = str(uuid.uuid4()).split("-")[0]
        if self.is_block():
            sig_type = 'Baking_' + payload_chainid
        else:
            sig_type = 'Endorsement_' + payload_chainid
        m = DynamoDbMutex(sig_type, holder=my_name, timeoutms=60 * 1000, region_name=ddb_region)
        locked = m.lock() # attempt to acquire the lock
        if locked:
            encoded_sig = ''
            data_to_sign = self.payload
            logging.info('About to sign {} with key handle {}'.format(data_to_sign, handle))
            if self.valid_block_format(data_to_sign):
                logging.info('Block format is valid')
                if self.is_block() or self.is_endorsement():
                    logging.info('Preamble is valid')
                    if self.not_already_signed():
                        if test_mode:
                            return self.TEST_SIGNATURE
                        else:
                            logging.info('About to sign with HSM client. Slot = {}, lib = {}, handle = {}'.format(self.hsm_slot, self.hsm_libfile, handle))
                            with HsmClient(slot=self.hsm_slot, pin=self.hsm_pin, pkcs11_lib=self.hsm_libfile) as c:
                                hashed_data = blake2b(hex_to_bytes(data_to_sign), digest_size=32).digest()
                                logging.info('Hashed data to sign: {}'.format(hashed_data))
                                sig = c.sign(handle=handle, data=hashed_data, mechanism=HsmMech.ECDSA)
                                logging.info('Raw signature: {}'.format(sig))
                                encoded_sig = RemoteSigner.b58encode_signature(sig)
                                logging.info('Base58-encoded signature: {}'.format(encoded_sig))
                    else:
                        logging.error('Invalid level')
                        m.release() # release the lock
                        raise Exception('Invalid level')
                else:
                    logging.error('Invalid preamble')
                    m.release() # release the lock
                    raise Exception('Invalid preamble')
            else:
                logging.error('Invalid payload')
                m.release() # release the lock
                raise Exception('Invalid payload')
            m.release() # release the lock
            return encoded_sig
        else: # lock could not be acquired
            logging.error('Could not acquire lock')
            raise Exception('Could not acquire lock') 
開發者ID:tacoinfra,項目名稱:remote-signer,代碼行數:51,代碼來源:remote_signer.py


注:本文中的pyblake2.blake2b方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。