python中最好/最容易使用的加密库是什么

python中最好/最容易使用的加密库是什么

what is the best/easiest to use encryption library in python

我想用 python 加密几个文件什么是最好的方法
我可以通过任何标准/著名的 python 库来使用 gpg/pgp 吗?


PyCrypto 似乎是最好的。


试试 KeyCzar

很容易实现。


我使用 GPGme GPGme 的主要优势在于它可以按照 OpenPGP 标准 (RFC 4880) 读写文件,如果您想与其他 PGP 程序进行互操作,这很重要。

它有一个 Python 接口。警告:这是一个低级接口,不是很 Pythonic。

如果您阅读法语,请查看示例。

这是一个,检查签名:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
signed = core.Data(sys.stdin.read())
plain = core.Data()
context = core.Context()

context.op_verify(signed, None, plain)
result = context.op_verify_result()

sign = result.signatures
while sign:
    if sign.status != 0:
        print"BAD signature from:"
    else:
        print"Good signature from:"
    print"  uid:       ", context.get_key(sign.fpr, 0).uids.uid
    print"  timestamp: ", sign.timestamp
    print"  fingerprint:", sign.fpr
    sign = sign.next

我使用 pyOpenSSL,它是一个用于 OpenSSL 的 python 绑定,已经存在了很长时间并且经过了很好的测试。我为我的应用程序做了一些基准测试,这是非常密集的加密货币,并且在与 pyCrypto 的比赛中胜出。 YMMV.


参见 Google 的 Keyczar 项目,它为 PyCrypto 的功能提供了一组很好的接口。


我喜欢 pyDes (http://twhiteman.netfirms.com/des.html)。它不是最快的,但它是纯 Python 并且非常适用于少量加密数据。


推荐阅读