PyCrypto支持PGP - 儘管你應該對其進行測試,以確保它的工作原理根據您的要求。
雖然文檔來之不易,如果你通過的Util/test.py(模塊測試腳本),你可以找到自己的PGP支持基本的例子:
if verbose: print ' PGP mode:',
obj1=ciph.new(password, ciph.MODE_PGP, IV)
obj2=ciph.new(password, ciph.MODE_PGP, IV)
start=time.time()
ciphertext=obj1.encrypt(str)
plaintext=obj2.decrypt(ciphertext)
end=time.time()
if (plaintext!=str):
die('Error in resulting plaintext from PGP mode')
print_timing(256, end-start, verbose)
del obj1, obj2
Futhermore,公鑰/ pubkey.py提供以下相關的方法:
def encrypt(self, plaintext, K)
def decrypt(self, ciphertext):
def sign(self, M, K):
def verify (self, M, signature):
def can_sign (self):
"""can_sign() : bool
Return a Boolean value recording whether this algorithm can
generate signatures. (This does not imply that this
particular key object has the private information required to
to generate a signature.)
"""
return 1
來源
2009-06-24 08:30:10
Jon
我看不到一種方法來生成密鑰,或接受另一方的公鑰來加密數據。有任何想法嗎? – Greg 2009-06-25 17:27:49
不,PyCrypto中的MODE_PGP是傳統的實驗性代碼,可能永遠不能正確工作。 (請參閱https://bugs.launchpad.net/pycrypto/+bug/996814)。不要使用它。無論如何,我們將很快從PyCrypto中刪除它。 – dlitz 2012-05-09 00:13:39
那麼你有什麼建議,@dlitz? – raylu 2013-07-17 22:50:55