4

Crypto.Random 可以用来安全地生成强密钥和初始化向量吗?

4

2 回答 2

8

根据PyCryto 文档,答案是肯定的:

from Crypto.PublicKey import RSA
from Crypto import Random
rng = Random.new().read
RSAkey = RSA.generate(1024, rng) 
于 2011-11-02T01:03:13.267 回答
-2

使用 pycrypto(此链接了解更多信息

>>> from Crypto.Hash import MD5
>>> MD5.new('abc').hexdigest()
'900150983cd24fb0d6963f7d28e17f72'

更安全(更多信息)?

>>> from versile.quick import VCrypto, VX509Crypto
>>> purpose  = 'Versily Python Demo Services'
>>> personal = 'I like Monty Python humor'
>>> password = 'kLqnr37ubG'
>>> identity = VCrypto.lazy().dia(1024, purpose, personal, password)
>>> type(identity)
<class 'versile.crypto.local._VLocalRSAKey'>
>>> x509_pubkey = VX509Crypto.export_public_key(identity.public)
>>> print(x509_pubkey) 
-----BEGIN RSA PUBLIC KEY-----
MIGJAoGBANpspNSQPXlq/tEBIq8pT31WYzcKFtX8b41k9ec5YqiJhgOf9WyK0UqTScOzLiySKun2
XBVjXRhok5kvyT32K+JYh2VwoOnS0J6KFOhaatKMvDmVIFyhAdZ7xC3+jf1zT0n/vAQE0+DEGKfS
de7je8eA/T4C7uwLKn98aY+oudFtAgMBAAE=
-----END RSA PUBLIC KEY-----
于 2012-12-15T17:31:25.717 回答