本文整理汇总了Python中dbclient.DbClient.calculateHash方法的典型用法代码示例。如果您正苦于以下问题:Python DbClient.calculateHash方法的具体用法?Python DbClient.calculateHash怎么用?Python DbClient.calculateHash使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dbclient.DbClient
的用法示例。
在下文中一共展示了DbClient.calculateHash方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testProfileHash
# 需要导入模块: from dbclient import DbClient [as 别名]
# 或者: from dbclient.DbClient import calculateHash [as 别名]
def testProfileHash(self):
# Clear out and reset own profile
myTorId = "ABC123DEF456GH78"
myprofile = {"name" : "Constantin Taylor", "keyid" : "someKeyId", "displayName" : "Me",
"status" : "self", "ownprofile" : True, "description":"Some fairly descriptive text",
"birthday":None, "interests":"chocolate pudding with fudge"}
DbClient.updateContact(myTorId, myprofile)
firstHash = DbClient.calculateHash(DbClient.getProfile())
self.assertEqual(firstHash, "12ae5c8dc8e1c2186b4ed4918040bb16", "First hash not what I was expecting")
# Now change interests and check that hash changes
DbClient.updateContact(myTorId, {"interests":"roasted vegetables and hummus"})
secondHash = DbClient.calculateHash(DbClient.getProfile())
self.assertNotEqual(firstHash, secondHash, "Profile hash should have changed")
示例2: _createSubpayload
# 需要导入模块: from dbclient import DbClient [as 别名]
# 或者: from dbclient.DbClient import calculateHash [as 别名]
def _createSubpayload(self):
'''Use the stored fields to pack the payload contents together'''
if self.profileHash is None or self.profileHash == "":
self.profileHash = DbClient.calculateHash(DbClient.getProfile())
return self.packBytesTogether([
self.encodeNumberToBytes(1 if self.online else 0, 1),
self.encodeNumberToBytes(1 if self.ping else 0, 1),
self.profileHash])