This project explores multiple cryptographic algorithms — RSA, ElGamal, and ECDSA — through manual implementations and secure library-based approaches, in both Java and Python.
The goal is to deeply understand cryptographic principles by implementing everything from scratch before applying industry-grade libraries like BouncyCastle and Python cryptography.
Disclaimer: This project is for educational and academic purposes only.
It is not intended for use in production systems or handling real-world sensitive data.
ELGamalMain.java
- Implements ElGamal encryption from scratch.
- Input: "This an lesson about Cryptography"
Output: Encrypted BigIntegers + original message restored.
RSAMain.java
- Implements RSA manually, including prime generation, public/private keys, encryption and decryption.
- Input: "This an lesson about Cryptography"
Output: Encrypted BigInteger + Decrypted message.
Main.java
- Full-feature cryptographic suite:
- ✔️RSA encryption/decryption
- ✔️RSA digital signatures (PSS + PKCS#1 v1.5)
- ✔️ECDSA signatures with verification
- All done with security-focused libraries including BouncyCastle.
- Outputs shown in both Hex and Base64.
RSA.py
- RSA encryption/decryption using cryptography primitives.
- Securely handles message encoding and decoding.
ELGamal.py
- ElGamal encryption using secure libraries (PyCryptodome / cryptography).
- Converts between bytes and strings, encrypts and decrypts securely.
- A custom key pair is generated (RSA or ElGamal).
- The string message is converted to a
BigInteger. - Encryption is performed using modular exponentiation.
- Decryption reverses the process and restores the original message.
- Uses BouncyCastle for RSA/ECDSA key generation and secure crypto operations.
- Message is converted to bytes, encrypted/decrypted.
- Digital signatures (RSA + ECDSA) are generated and verified.
- Cryptographic keys are securely generated with the
cryptographymodule. - Messages are encoded into bytes.
- Encryption, decryption, and signature processes are securely handled using trusted libraries.
- Clone the repository:
git clone https://github.com/YOUR_USERNAME/cryptography-playground.git - Navigate to the project directory:
cd cryptography-playground
- Compile and run the desired script:
javac RSAMain.javajava RSAMain - Or for the advanced project:
javac Main.javajava Main
Make sure to include all .java dependencies in the same directory or classpath.
- Install requirements (if any) and run:
pip install cryptography pycryptodomepython RSA.pypython ELGamal.py
No command-line parameters are required — messages are defined directly in the code for clarity. You can change them manually in the scripts.
Feel free to contribute! Open a pull request or create an issue to suggest improvements or new crypto features. Collaboration is welcome — especially if you're experimenting with new algorithms or padding schemes.
This project is licensed under the MIT License. See LICENSE for more details.