可以使用Crypto.Random安全地生成强密钥和初始化向量吗?
答案 0 :(得分:9)
根据PyCryto docs,答案是肯定的:
from Crypto.PublicKey import RSA
from Crypto import Random
rng = Random.new().read
RSAkey = RSA.generate(1024, rng)
答案 1 :(得分:0)
使用pycrypto(This link for more info)
>>> from Crypto.Hash import MD5
>>> MD5.new('abc').hexdigest()
'900150983cd24fb0d6963f7d28e17f72'
更安全(For more info)?
>>> 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-----