本文整理匯總了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])