Highlights
Learning Outcomes
Upon successful completion of this practical task you will be able to:
• Explain how characters and other symbols are stored on computers using the ASCII system of encoding.
• Demonstrate how to use casting functions in MATLAB to modify data-types.
• Design and implement an algorithm utilising conditional/iterative programming structures and user- defined functions.
Introduction to the practical
‘Secret codes’ or ciphers have been around for hundreds if not thousands of years and have been used throughout history to secure communication between groups of people.
Often ciphers have been used in times of war to ensure sensitive information is communicated only to certain people; even if the enemy intercepts the communication all they should be able to read is gibberish unless they know the appropriate key to use to decrypt the message.
One well-known example of a cipher was the Enigma code used by the German military during World War II, since then ciphers have extended into the realms of computer science and computer network security with very complex algorithms now being used to encrypt communication between computers. Modern encryption schemes include algorithms such as the Advanced Encryption Standard (AES), the Rivest-Shamir- Adleman (RSA) system and the Transport Layer Security (TLS) system.
Task 1 – State the Problem and Determine the Input/Output
Exercise: Using the information given on the previous page state the problem concisely and determine the input you have/need to solve the problem and what you need to output to accomplish the objective.
Points to be addressed:
- The problem statement should be clear and concise, double-check with your tutor if you are not sure of anything written in the problem statement. - What input/output data types do you need (numeric, words, images,
graphical output?). - What assumptions are you making (if any) to help you solve/simplify the problem?
Task 2 – Design your Algorithms
Exercise: Using the information from task 1 and your preliminary task, design how you should structure your program and the steps needed to perform the task. Note a few important requirements for your program:
- You need to have at least one user-defined function to encrypt/decrypt the message. - You need at least one other script that obtains the message to be encoded and calls the functions that perform the encrypting/decrypting.
Points to be addressed:
- Make sure you check your algorithm will work using a short test message. - Make sure you show the manual working for this part and ensure this working is neatly typed (not handwritten) in your write-up.
Task 3 – Write your program
Exercise: Now, in a new MATLAB script file write the program that will encrypt and decrypt your message.
Points to be addressed:
- Compare the answers you get from MATLAB to your handworked
answers from task 2. They should be the same, if not troubleshoot your algorithm/script to find where the mistake is. - Also, help your colleagues test their solutions by writing an
encrypted message into a text file. Give that text file to your colleagues along with the encryption key you used and see if their program can decode your message. - Below is some code that will write the data to a text file and read it back into MATLAB:
% Write encoded message to a text file fid = fopen('mycode.txt', 'w'); % Open the file for write access 'w' fwrite(fid, codedmessage); % Write message to open file fclose(fid); % important, we must release the file back to the Operating System after we're done
% Read encoded message from a text file fid = fopen('mycode.txt', 'r'); % Open the file for read access 'r' codedmessage = fread(fid); % Read the data out of the file fclose(fid); % important, we must release the file back to the Operating System after we're done
Part 3 (week 7): A Brute-Force Decryption Algorithm
Breaking a code is always a security concern with any cipher. Our cipher is not particularly sophisticated so would take very little to break; there are only 256 possible combinations of encryption keys in our scheme which can be easily broken using a ‘brute-force’ attack.
A brute-force attack on this type of cipher could utilise an exhaustive key search method which will basically try every possible encryption key combination against your encrypted message.
For this part of the practical create a function that can brute-force decode an encrypted message without knowing the encryption key that was used by using an exhaustive key search method.
Task 4 – State the Problem and Determine the Input/Output
Exercise: Using the information given state the new problem concisely and determine the input you have/need to solve the problem and what you need to output to accomplish the objective.
Points to be addressed:
- The problem statement should be clear and concise, double-check with your tutor if you are not sure of anything written in the problem statement. - What input/output data types do you need (numeric, words, images,
graphical output?). - What assumptions are you making (if any) to help you solve/simplify the problem.
Task 5 – Design your New Algorithm
Exercise: Design how you should structure this part of the program and the steps your program will need to perform to achieve the objective.
Points to be addressed:
- Make sure you check your algorithm will work, step through the logic and make sure it can achieve the objective.
Task 6 – Use MATLAB to Solve the Problem
Exercise: Now, in MATLAB write the code to perform your brute-force attack.
Points to be addressed:
- Compare the answers from MATLAB to what you expect, make sure your original message is shown somewhere in your output. If the original message is nowhere to be seen troubleshoot your algorithm/script to find where the mistake is. - Again, you can help your colleagues test their solutions by writing an encrypted message into a text file (using the same method as in Task 3). Give that text file to your colleagues without the encryption key this time and see if their program can decode your message.
This Engineering Assignment has been solved by our Engineering Experts at My Uni Paper. Our Assignment Writing Experts are efficient to provide a fresh solution to this question. We are serving more than 10000+ Students in Australia, UK & US by helping them to score HD in their academics. Our Experts are well trained to follow all marking rubrics & referencing style.
Be it a used or new solution, the quality of the work submitted by our assignment experts remains unhampered. You may continue to expect the same or even better quality with the used and new assignment solution files respectively. There’s one thing to be noticed that you could choose one between the two and acquire an HD either way. You could choose a new assignment solution file to get yourself an exclusive, plagiarism (with free Turnitin file), expert quality assignment or order an old solution file that was considered worthy of the highest distinction.
© Copyright 2026 My Uni Papers – Student Hustle Made Hassle Free. All rights reserved.