为什么GnuPG解密速度如此之低
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了为什么GnuPG解密速度如此之低相关的知识,希望对你有一定的参考价值。
解密速度比加密快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("", 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))
答案
[GPG使用RSA,根据this answer,RSA解密比加密慢是完全正常的,因为私钥需要很长,但公钥不一定。
另一答案
请注意,您的解密采用密码而不是加密。这是因为私钥位于加密的密钥环中。此密码短语上使用的密钥偏离过程正确地是一个迭代过程,需要花费一些时间。
可能是这个:迭代并加盐s2kiterated-and-salted-s2k
以上是关于为什么GnuPG解密速度如此之低的主要内容,如果未能解决你的问题,请参考以下文章
为啥使用 Faster RCNN 在 GPU 上进行自定义对象检测的预测率 25 - 40 [sec/1] 如此之低?