In this assignment you will develop a simple Android app, SDPEncryptor, that encrypts messages using a simple substitution cipher.
INPUTS:
1. Message, to be encoded.
This input should be a non-empty string and must contain at least one letter.
This input should be provided to the app through an EditText widget, initially blank.
2. Key Number, a parameter for the encryption
This input should be an integer >= 1 and < 26.
This input should be provided to the app through an EditText widget, initially set to '0'.
3. Increment Number, a parameter for the encryption
This input should be an integer >= 1 and < 26.
This input should be provided to the app through an EditText widget, initially set to '0'.
OUTPUT:
1. Encrypted Message, the text resulting from applying the following cipher:
The first letter in the message (a-z, A-Z) will be replaced by the letter that is N number of positions down the alphabet, where N is the Key Number, as in a Caesar Cipher.
Each following letter in the message will be replaced by the letter that is M number of positions down the alphabet, where M is obtained by
computing the sum of (1) Key Number and (2) Increment Number multiplied by the number of letters shifted so far, and
taking the modulo 26 of the result, so that M is always between 0 and 25.
All non-alphabetic characters must remain unchanged.
Capitalization of alphabetic characters is inverted (i.e., all lowercase characters are transformed into upper case characters and vice versa).
The output should be shown using a non-editable TextView that is initially blank and (re)computed every time the "ENCRYPT" button is pressed. If any input is invalid when the button is pressed, the output should then be set to (i.e., the empty string), and all applicable error messages should be generated (see below).
EXAMPLE:
Input:
Message = "Cat & Dog"
Key Number = 3
Increment Number = 2
Output:
Encryped Message = "fFA & mZT"
(C + 3, a + 5, t + 7, ' ', &, ' ', D + 9, o + 11, g + 13)
ERROR MESSAGES:
The app should generate suitable error messages by calling EditText's setError method (inherited from TextView) on the appropriate EditText widget. If done correctly, this will result in (1) an error mark "!" on the right-hand side of the text field and (2) a floating error message whenever the field has focus, as shown in the error screenshots below. It is possible to have more than one error active at the same time, as also shown in the screenshots below.
There are three error situations:
"Invalid Message", related to the Message field, for an empty or letterless entry.
"Invalid Key Number", related to the Key Number field, for a blank or out-of-range value.
"Invalid Increment Number", related to the Increment Number field, for a blank or out-of-range value.
Note: You may either limit the input in the numerical fields to positive numbers or provide the same errors if negative numbers or non-numerical input are entered.
For illustration, we are providing several screenshots for a possible implementation of the app: see image.
We suggest that you try to generate a user interface (UI) similar to the one shown above, but you don't have to. However, you must make sure to use the exact same identifiers we provide below for your widgets. This is very important, as we will use these identifiers to check and auto-grade your app
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference
and should not be submitted as is. We are not held liable for any misuse of the solutions.
Please see the frequently asked questions page
for further questions and inquiries.
Kindly complete the form.
Please provide a valid email address and we will get back to you within 24 hours.
Payment is through PayPal, Buy me a Coffee
or Cryptocurrency.
We are a nonprofit organization however we need funds to keep this organization operating
and to be able to complete our research and development projects.