This project implements a basic RSA encryption and decryption algorithm in PHP from scratch. The implementation includes generating prime numbers, computing the necessary keys, and using those keys to encrypt and decrypt messages.
RSA (Rivest-Shamir-Adleman) is an asymmetric cryptographic algorithm used for secure data transmission. This project demonstrates the key steps involved in RSA encryption:
- Prime number generation
- Key generation (public and private keys)
- Encryption using the public key
- Decryption using the private key
- PHP 7.2 or higher
- GMP extension for PHP
- Ensure PHP and GMP extension are installed on your system.
- Clone this repository or download the source code.
Run the PHP script to see the RSA encryption and decryption in action.
php rsa_encryption.php
In the file rsa_encryption.php you will find an example of how to use the functions to encrypt and decrypt a message.
This example uses small prime numbers for simplicity. In a real-world scenario, use much larger primes for security. The message to be encrypted should be numeric in this basic implementation. For more practical use, consider converting text to numeric form before encryption.