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


Python ElGamal.construct方法代碼示例

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


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

示例1: test_encryption

# 需要導入模塊: from Crypto.PublicKey import ElGamal [as 別名]
# 或者: from Crypto.PublicKey.ElGamal import construct [as 別名]
def test_encryption(self):
        for tv in self.tve:
            for as_longs in (0,1):
                d = self.convert_tv(tv, as_longs)
                key = ElGamal.construct(d['key'])
                ct = key.encrypt(d['pt'], d['k'])
                self.assertEquals(ct[0], d['ct1'])
                self.assertEquals(ct[1], d['ct2']) 
開發者ID:adde88,項目名稱:hostapd-mana,代碼行數:10,代碼來源:test_ElGamal.py

示例2: test_decryption

# 需要導入模塊: from Crypto.PublicKey import ElGamal [as 別名]
# 或者: from Crypto.PublicKey.ElGamal import construct [as 別名]
def test_decryption(self):
        for tv in self.tve:
            for as_longs in (0,1):
                d = self.convert_tv(tv, as_longs)
                key = ElGamal.construct(d['key'])
                pt = key.decrypt((d['ct1'], d['ct2']))
                self.assertEquals(pt, d['pt']) 
開發者ID:adde88,項目名稱:hostapd-mana,代碼行數:9,代碼來源:test_ElGamal.py

示例3: test_signing

# 需要導入模塊: from Crypto.PublicKey import ElGamal [as 別名]
# 或者: from Crypto.PublicKey.ElGamal import construct [as 別名]
def test_signing(self):
        for tv in self.tvs:
            for as_longs in (0,1):
                d = self.convert_tv(tv, as_longs)
                key = ElGamal.construct(d['key'])
                sig1, sig2 = key.sign(d['h'], d['k'])
                self.assertEquals(sig1, d['sig1'])
                self.assertEquals(sig2, d['sig2']) 
開發者ID:adde88,項目名稱:hostapd-mana,代碼行數:10,代碼來源:test_ElGamal.py

示例4: test_verification

# 需要導入模塊: from Crypto.PublicKey import ElGamal [as 別名]
# 或者: from Crypto.PublicKey.ElGamal import construct [as 別名]
def test_verification(self):
        for tv in self.tvs:
            for as_longs in (0,1):
                d = self.convert_tv(tv, as_longs)
                key = ElGamal.construct(d['key'])
                # Positive test
                res = key.verify( d['h'], (d['sig1'],d['sig2']) )
                self.failUnless(res)
                # Negative test
                res = key.verify( d['h'], (d['sig1']+1,d['sig2']) )
                self.failIf(res) 
開發者ID:adde88,項目名稱:hostapd-mana,代碼行數:13,代碼來源:test_ElGamal.py

示例5: test_encryption

# 需要導入模塊: from Crypto.PublicKey import ElGamal [as 別名]
# 或者: from Crypto.PublicKey.ElGamal import construct [as 別名]
def test_encryption(self):
        for tv in self.tve:
            for as_longs in (0,1):
                d = self.convert_tv(tv, as_longs)
                key = ElGamal.construct(d['key'])
                ct = key.encrypt(d['pt'], d['k'])
                self.assertEqual(ct[0], d['ct1'])
                self.assertEqual(ct[1], d['ct2']) 
開發者ID:Desgard,項目名稱:Repobot,代碼行數:10,代碼來源:test_ElGamal.py

示例6: test_decryption

# 需要導入模塊: from Crypto.PublicKey import ElGamal [as 別名]
# 或者: from Crypto.PublicKey.ElGamal import construct [as 別名]
def test_decryption(self):
        for tv in self.tve:
            for as_longs in (0,1):
                d = self.convert_tv(tv, as_longs)
                key = ElGamal.construct(d['key'])
                pt = key.decrypt((d['ct1'], d['ct2']))
                self.assertEqual(pt, d['pt']) 
開發者ID:Desgard,項目名稱:Repobot,代碼行數:9,代碼來源:test_ElGamal.py

示例7: test_signing

# 需要導入模塊: from Crypto.PublicKey import ElGamal [as 別名]
# 或者: from Crypto.PublicKey.ElGamal import construct [as 別名]
def test_signing(self):
        for tv in self.tvs:
            for as_longs in (0,1):
                d = self.convert_tv(tv, as_longs)
                key = ElGamal.construct(d['key'])
                sig1, sig2 = key.sign(d['h'], d['k'])
                self.assertEqual(sig1, d['sig1'])
                self.assertEqual(sig2, d['sig2']) 
開發者ID:Desgard,項目名稱:Repobot,代碼行數:10,代碼來源:test_ElGamal.py

示例8: test_verification

# 需要導入模塊: from Crypto.PublicKey import ElGamal [as 別名]
# 或者: from Crypto.PublicKey.ElGamal import construct [as 別名]
def test_verification(self):
        for tv in self.tvs:
            for as_longs in (0,1):
                d = self.convert_tv(tv, as_longs)
                key = ElGamal.construct(d['key'])
                # Positive test
                res = key.verify( d['h'], (d['sig1'],d['sig2']) )
                self.assertTrue(res)
                # Negative test
                res = key.verify( d['h'], (d['sig1']+1,d['sig2']) )
                self.assertFalse(res) 
開發者ID:Desgard,項目名稱:Repobot,代碼行數:13,代碼來源:test_ElGamal.py


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