本文整理汇总了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'])
示例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'])
示例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'])
示例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)
示例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'])
示例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'])
示例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'])
示例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)