本文整理汇总了Python中crypto2crypto.CryptoTransportLayer.makeCryptor方法的典型用法代码示例。如果您正苦于以下问题:Python CryptoTransportLayer.makeCryptor方法的具体用法?Python CryptoTransportLayer.makeCryptor怎么用?Python CryptoTransportLayer.makeCryptor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类crypto2crypto.CryptoTransportLayer
的用法示例。
在下文中一共展示了CryptoTransportLayer.makeCryptor方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: update_listings_index
# 需要导入模块: from crypto2crypto import CryptoTransportLayer [as 别名]
# 或者: from crypto2crypto.CryptoTransportLayer import makeCryptor [as 别名]
def update_listings_index(self):
# Store to marketplace listing index
contract_index_key = hashlib.sha1('contracts-%s' %
self.transport.guid).hexdigest()
hashvalue = hashlib.new('ripemd160')
hashvalue.update(contract_index_key)
contract_index_key = hashvalue.hexdigest()
# Calculate index of contracts
contract_ids = self.db.selectEntries("contracts",
"market_id = '%s'" %
self.transport.market_id.replace("'", "''"))
my_contracts = []
for contract_id in contract_ids:
my_contracts.append(contract_id['key'])
self.log.debug('My Contracts: %s' % my_contracts)
# Sign listing index for validation and tamper resistance
data_string = str({'guid': self.transport.guid,
'contracts': my_contracts})
signature = CryptoTransportLayer.makeCryptor(self.transport.settings['secret']).sign(data_string).encode('hex')
value = {'signature': signature,
'data': {'guid': self.transport.guid,
'contracts': my_contracts}}
# Pass off to thread to keep GUI snappy
self.transport.dht.iterativeStore(self.transport,
contract_index_key,
value, self.transport.guid)