解密速度是加密速度的20倍!结果显示,加密时间为14.238579760014545(1000次),解密时间为339.19246241397923(1000次)。
CPU:3.60GHz×8时,英特尔®酷睿™i7-4790 CPU
内存:15.6 GiB
操作系统:Ubuntu 18
import timeit
mysetup = '''
import gnupg
'''
encrypt_code = '''
gpg = gnupg.GPG(gnupghome='gpghome')
text="""Or kind rest bred with am shed then. In raptures building an bringing be. Elderly is detract tedious assured private so to visited. Do travelling companions contrasted it. Mistress strongly remember up to. Ham him compass you proceed calling detract. Better of always missed we person mr. September smallness northward situation few her certainty something.
An sincerity so extremity he additions. Her yet there truth merit. Mrs all projecting favourable now unpleasing. Son law garden chatty temper. Oh children provided to mr elegance marriage strongly. Off can admiration prosperous now devonshire diminution law. """
status = gpg.encrypt(text, recipients=['testgpguser@mydomain.com'])
'''
decrypt_code = '''
gpg = gnupg.GPG(gnupghome='gpghome')
enc_text=b"-----BEGIN PGP MESSAGE-----\\n\\nhQEMA0GPN4kKbscAAQf/RNDIh8LqxJi572Kd330Fx0DmYVMBnLy8Bcn0z4vZNpIM\\njkXdnH3aqOGD+/2ToIGhgGZue46ZDc/J2pdTze1wJsP20E1q04v/J3lihRa368cc\\nYfD4Za0egt7mY1LeW7ABXzqQ3Ni1hLP97wOHe1WSfM7csOXv4xfIREM2e6IOvJ4C\\nwIrgReQbHNbEtLw3NxINevj8YVPuILJp6IDcbDtieLexTS2y66j7GazSDZRZgHLi\\nu4qE8P4Oq6sf1f0YSQI4oeQrtVKEfIIFyb/SNag1FrqRLjF3TGM22OUIIoCleYdN\\nzyv1tEeulU9h1+QYogSa7BxYB9pmW6keA8d/QdkG09I7AXXVdGL9mq0cLVqReXyC\\nqCDvnejwcM8E5ceHZR8KGm+9jVB+hcxC2HJ3TABnFNUeHMknVvLoFP9xMe0=\\n=KSv4\\n-----END PGP MESSAGE-----\\n"
status = gpg.decrypt(enc_text, passphrase='my passphrase')
'''
print(timeit.timeit(setup=mysetup, stmt=encrypt_code, number=1000))
print(timeit.timeit(setup=mysetup, stmt=decrypt_code, number=1000))
答案 0 :(得分:1)
GPG使用RSA,根据guidelines,RSA解密比加密慢是完全正常的,因为私钥需要很长,但公钥不一定。
答案 1 :(得分:1)
请注意,您的解密采用密码而不是加密。这是因为私钥位于加密的密钥环中。此密码短语使用的关键偏离过程正确地是一个迭代过程,需要花费一些时间。
可能是这个:iterated-and-salted-s2k