“Python gera par de chaves RSA” Respostas de código

Python gera par de chaves RSA

# download pycryptodome by running 'pip3 install pycryptodome'

from Crypto.PublicKey import RSA

private_key = RSA.generate(2048)
pubkey = private_key.publickey()

private_key = private_key.exportKey().decode("utf-8")
pubkey = pubkey.exportKey().decode("utf-8")
Thoughtless Thrush

Python gera par de chaves privadas públicas

from cryptography.hazmat.primitives import serialization as crypto_serialization
from cryptography.hazmat.primitives.asymmetric import rsa
from cryptography.hazmat.backends import default_backend as crypto_default_backend

key = rsa.generate_private_key(
    backend=crypto_default_backend(),
    public_exponent=65537,
    key_size=2048
)

private_key = key.private_bytes(
    crypto_serialization.Encoding.PEM,
    crypto_serialization.PrivateFormat.PKCS8,
    crypto_serialization.NoEncryption()
)

public_key = key.public_key().public_bytes(
    crypto_serialization.Encoding.OpenSSH,
    crypto_serialization.PublicFormat.OpenSSH
)
Fine Falcon

Respostas semelhantes a “Python gera par de chaves RSA”

Perguntas semelhantes a “Python gera par de chaves RSA”

Mais respostas relacionadas para “Python gera par de chaves RSA” em Python

Procure respostas de código populares por idioma

Procurar outros idiomas de código