0
from cryptography.hazmat.backends import default_backend
from cryptography.hazmat.primitives import hashes
from cryptography.hazmat.primitives.asymmetric import padding
from cryptography.hazmat.primitives.asymmetric import rsa
#gerando a chave privada
private_key = rsa.generate_private_key(
public_exponent=65537,
key_size=2048,
backend=default_backend()
)
#gerando chave publica
public_key = private_key.public_key()
senha_cripto = str(input("Senha para criptografar:")).strip()
while senha_cripto != 'batata':
print("Senha incorreta, tente novamente!")
senha_cripto = str(input("Senha para criptografar:")).strip()
if senha_cripto == 'batata':
break;
mensagem = str(input("escreva uma mensagem:"))
texto_cifrado = public_key.encrypt(
mensagem,
padding.OAEP(
mgf=padding.MGF1(algorithm=hashes.SHA1()),
algorithm=hashes.SHA1(),
label=None
)
)
print(texto_cifrado)
normaltext = private_key.decrypt(
mensagem,
padding.OAEP(
mgf=padding.MGF1(algorithm=hashes.SHA1()),
algorithm=hashes.SHA1(),
label=None
)
)
print(normaltext)
Nathalia where is the error? Please post the LOG to make it easier to help
– Clayton Tosatti
hello, when I put message = b'what will be encrypted it right'
– Nathalia Dias
but when I put the text as message = str(input("write a message:"))
– Nathalia Dias