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