Pycrypto - Using Crypto.Random to generate a secret key and an initialisation vector
Frage
Can Crypto.Random be used to safely generate a strong secret key and an initialisation vector?
Lösung
According to the PyCryto docs, the answer is yes:
from Crypto.PublicKey import RSA
from Crypto import Random
rng = Random.new().read
RSAkey = RSA.generate(1024, rng)
Andere Tipps
Using pycrypto(This link for more info)
>>> from Crypto.Hash import MD5
>>> MD5.new('abc').hexdigest()
'900150983cd24fb0d6963f7d28e17f72'
More security(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-----
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow