本文整理汇总了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}
示例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!')
示例3: blake
# 需要导入模块: import pyblake2 [as 别名]
# 或者: from pyblake2 import blake2b [as 别名]
def blake(x):
return blake2b(x).digest()[:32]
示例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
示例5: H
# 需要导入模块: import pyblake2 [as 别名]
# 或者: from pyblake2 import blake2b [as 别名]
def H(m):
return bytearray(blake2b(m).digest())
示例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
示例7: blake2b_32
# 需要导入模块: import pyblake2 [as 别名]
# 或者: from pyblake2 import blake2b [as 别名]
def blake2b_32(v=b''):
return blake2b(scrub_input(v), digest_size=32)
示例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()
示例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')