This project implements the ElGamal Public-Key Encryption scheme in C++ using the BigInt library for working with large integers. The program allows users to generate public and private keys, encrypt plaintext messages, and decrypt ciphertext messages.
- Language: C++11 or older
- BigInt
BigInt
: Contains the BigInt header filebigint.h
: BigInt header file also containing inline implementations
ElGamal
: Containts the ElGamal header file and implementation fileelgamal.h
: Contains header for libraries included, functions, and public key variableselgamal.cpp
: Implementation file containing implementation of all ElGamal functions
main.cpp
: Main file implementating the console interface for encryting and decryting messages
- Open the
main.cpp
directory. - Build and Run
- If there is error linking the files
- Open the
tasks.json
file in your Visual Studio Code workspace (.vscode
directory) - Ensure that the
args
property within the"tasks"
array looks like the following:"args": [ "-fdiagnostics-color=always", "-g", "main.cpp", // Compile main.cpp "ElGamal/elgamal.cpp", // Compile ElGamal/elgamal.cpp "-I", "BigInt", // Include BigInt folder "-o", "${fileDirname}\\${fileBasenameNoExtension}.exe" ],
- Save the
tasks.json
file. - Build and Run in
main.cpp
- Open the
- Build:
g++ -o output.exe main.cpp ElGamal/elgamal.cpp -I BigInt -std=c++11
- Run:
./main.exe
- Follow the on-screen instructions provided by the program:
- Encryption
- Type 'E' to encrypt a message
- Enter message for encrytion
- Enter desire key size(must be larger than message)
- [!WARNING] encryption will take longer with large messages and key size
- You be provided with the public key, secret private key, and cipher text γ and δ
- Decryption (must first encrypt a message while program is running to decrypt)
- Provide γ and δ and private key
- You will be provided the original message.
- Encryption