├── README.md └── RSA_Encrypt_and_Decrypt.py /README.md: -------------------------------------------------------------------------------- 1 | # RSA_Encrypt_and_Decrypt 2 | This project creates a simple RSA cipher in Python. It uses the RSA library to generate a public and private key pair. For educational purposes only. 3 | 4 | @blindma1den 5 | 6 | This project creates a simple RSA cipher in Python. It uses the RSA library to generate a public and private key pair. The public key is used to encrypt a message, and the private key is used to decrypt the encrypted message. 7 | 8 | To run the project, save the file as cipher.py and then run the following command: 9 | 10 | python cipher.py 11 | The output should be the following: 12 | 13 | This is an encrypted message 14 | You can modify the code to encrypt and decrypt messages of any length. You can also modify the size of the keys to increase or decrease security. 15 | 16 | Here are the specific instructions for each function in the code: 17 | 18 | generar_claves(): This function generates a public and private key pair of 2048 bits. 19 | cifrar(): This function encrypts a message using the public key. 20 | descifrar(): This function decrypts an encrypted message using the private key. 21 | The main() function first generates a public and private key pair. It then encrypts a message using the public key and prints the encrypted message. Finally, it decrypts the encrypted message using the private key and prints the decrypted message. 22 | 23 | You can modify the code to do different things. For example, you could change the message to encrypt or decrypt. You could also change the size of the keys to increase or decrease security. 24 | 25 | Here are some specific things you could do to modify the code: 26 | 27 | To encrypt a different message, change the value of the mensaje variable in the main() function. 28 | To change the size of the keys, change the value of the bits argument in the newkeys() function. 29 | To add more security, increase the size of the keys. 30 | To reduce security, decrease the size of the keys. 31 | 32 | @blindma1den 33 | 34 | HAPPY HACKING! 35 | 36 | -------------------------------------------------------------------------------- /RSA_Encrypt_and_Decrypt.py: -------------------------------------------------------------------------------- 1 | import rsa 2 | 3 | def generar_claves(): 4 | # Genera un par de claves RSA de 2048 bits 5 | clave_publica, clave_privada = rsa.newkeys(2048) 6 | 7 | return clave_publica, clave_privada 8 | 9 | def cifrar(mensaje, clave_publica): 10 | # Cifra un mensaje usando la clave pública 11 | cypher = rsa.encrypt(mensaje.encode("utf-8"), clave_publica) 12 | 13 | return cypher 14 | 15 | def descifrar(cypher, clave_privada): 16 | # Descifra un mensaje cifrado usando la clave privada 17 | mensaje = rsa.decrypt(cypher, clave_privada).decode("utf-8") 18 | 19 | return mensaje 20 | 21 | if __name__ == "__main__": 22 | # Generamos un par de claves 23 | clave_publica, clave_privada = generar_claves() 24 | 25 | # Ciframos un mensaje 26 | mensaje = "Este es un mensaje cifrado" 27 | cypher = cifrar(mensaje, clave_publica) 28 | 29 | # Desciframos el mensaje 30 | mensaje_descifrado = descifrar(cypher, clave_privada) 31 | 32 | print(mensaje_descifrado) --------------------------------------------------------------------------------