An Innovative Approach to Secure Morse Code Communication
This project is a Morse Code Translator developed as part of the Milestone 2 assignment for the Databases and Data Structures module. The system uses a binary tree structure for efficient Morse code encoding and decoding, with added features like message reversal for enhanced security. The project demonstrates expertise in implementing data structures, algorithmic thinking, and security measures.
- Maps Morse code sequences to characters using left (dot) and right (dash) node traversal.
- Supports efficient encoding and decoding operations.
- Reverses the Morse code message before or after translation to add obfuscation and improve security.
- Decoding and encoding operations are performed in (O(k)), where (k) is the Morse code length for each character.
- Ensures input contains only valid Morse code symbols (
.
,-
,/
, spaces). - Provides error messages for empty, null, or invalid inputs.
- Programming Language: Java
- Data Structures: Binary tree, stack
- Algorithm: Custom encoding/decoding with a reversal feature for security
- Java Development Kit (JDK) installed
- Text editor or IDE (e.g., IntelliJ IDEA, Eclipse)
- Morse code data files (
character_codes.txt
,sample_code.txt
)
-
Clone the repository:
git clone https://github.com/your-username/morse-code-translator.git cd morse-code-translator
-
Ensure the required input files (
character_codes.txt
,sample_code.txt
) are in the project directory. -
Compile the Java files:
javac *.java
-
Run the application:
java Milestone2App
-
Encoding Messages:
- Input a text message to convert it into Morse code.
- Optionally reverse the code for added security.
-
Decoding Messages:
- Provide a Morse code sequence to retrieve the original message.
- For reversed messages, enable the reversal option before decoding.
-
Printing the Morse Code Dictionary:
- View all character-to-code mappings by traversing the binary tree.
TreeNode.java
: Represents nodes in the Morse code tree.StackNode.java
: Supports in-order traversal without recursion.MorseCodeTree.java
: Handles tree creation, insertion, and traversal logic.Milestone2App.java
: Main application class for encoding, decoding, and managing input/output.
- Insertion: Characters are added by traversing the tree based on dots (left) and dashes (right).
- Decoding: Each Morse code sequence is decoded by traversing from the root to the corresponding node.
- Adds security by reversing the message (e.g.,
... --- ...
becomes... --- ...
in reverse). - Reversal is performed in-place for efficiency.
- Ensures the input is not null, empty, or contains invalid characters.
- Encoding/Decoding: (O(k)) per character.
- Reversal: (O(m)), where (m) is the length of the Morse code message.
Test Case | Input | Expected Output | Result |
---|---|---|---|
Valid Morse Code | ... --- ... |
Decoded: "SOS" | Pass |
Empty Input | (empty) | Error: "The Morse code message is empty." | Pass |
Invalid Characters | ... --- @@@ |
Error: "Invalid characters in the message." | Pass |
Valid Morse Code with Reversal | ... --- ... (reversed) |
Decoded: "SOS" | Pass |
Contributions are welcome! Fork the repository, make changes, and submit a pull request.
This project is licensed under the MIT License.
- Email: [email protected]