This project focus on the development of the messaging algorithm that combines Huffman coding for data compression and the Diffie-Hellman algorithm for secure key exchange.
This Java program consists of two main components:
- DiffieHellman.java: Implements the Diffie-Hellman key exchange algorithm, allowing two parties to securely generate a shared secret key.
- HuffmanCoding.java: Implements the Huffman coding algorithm for text compression and decompression.
The Diffie-Hellman key exchange algorithm is used to securely exchange secret keys over an unsecured communication channel. It includes the following steps:
- Two parties, Alice and Bob exchange public values generated based on a shared prime number and generator.
- They demonstrate the encryption and decryption of a message using these shared keys.
- A simulation is included where an eavesdropper attempts to decrypt the message without the correct key.
- Message encryption involves adding a key to ASCII codes.
- Message decryption reverses this process, subtracting the key.
Huffman coding is a lossless data compression algorithm. It includes the following steps:
- Calculate the frequency of each character in the input text.
- Build a Huffman tree using the character frequencies.
- Generate binary codes for each character based on the tree.
- Encode the input text using the generated Huffman codes.
- Decode the encoded text to recover the original input text.
To use this program, follow these steps:
-
Compile the Java files:
javac DiffieHellman.java HuffmanCoding.java -
Run the program:
java DiffieHellman
The program will perform the following steps:
- Generate Diffie-Hellman public and private keys for Alice and Bob.
- Exchange public keys between Alice and Bob.
- Encrypt and decrypt a sample message using the shared secret key.
- Demonstrate how an eavesdropper without the correct key cannot decrypt the message.
This program uses the Java standard library and does not require any external dependencies.