当前位置: 首页>>代码示例>>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;未经允许,请勿转载。