This project provides a basic example of using the OpenSSL library in a C/C++ program. It demonstrates how to generate an RSA key pair, perform encryption and decryption using the keys, and save the keys to PEM files.
- Clone the repository or download the source code files.
git clone https://github.com/guy-davidi/OpenSSLexProject.git
- Compile the source code using the following command:
gcc openssl_example.c -o example -lssl -lcrypto
Make sure to replace openssl_example.c
with the actual filename if necessary.
- Run the compiled program:
./example
-
The program will generate an RSA key pair and save the private key and public key to separate PEM files (
private_key.pem
andpublic_key.pem
). -
The program will encrypt and decrypt a sample message using the generated keys, demonstrating the encryption and decryption process.
-
The decrypted message will be displayed on the console.
-
You can modify the
RSA_KEY_LENGTH
constant in the source code to change the key length (in bits) for the generated RSA key pair. The default value is 2048 bits. -
Feel free to modify the sample message in the source code to encrypt and decrypt your own messages.
Contributions to this project are welcome. If you encounter any issues or have suggestions for improvements, please submit an issue or a pull request.
This project is licensed under the MIT License