Maze Traversal, Graphs, Equivalence Classes-Spring 2018

这是一篇关于SDP加密器的程序代写

 

In this assignment, you will develop a simple Android app, SDPEncryptor, that encrypts messages using a simple substitution cipher.

INPUTS:

  1. Entry Text: message to be encoded.
  • This input should be a non-empty string and must contain at least one letter or number.
  • This input should be provided to the app through an EditText widget, initially blank.
  1. Arg Input 1: first encryption parameter.
  • This input should be an integer coprime to 36 between 0 and 36: 1, 5, 7, 11, 13, 17, 19,23, 25, 29, 31, or 35.
  • This input should be provided to the app through an EditText widget, initially set to ‘1’.
  1. Arg Input 2: second encryption parameter.
  • This input should be an integer >= 1 and < 36.
  • This input should be provided to the app through an EditText widget, initially set to ‘1’.

OUTPUT:

  1. Text Encrypted, the text resulting from applying the following cipher:
  • Each character in the alphabet is assigned a numeric value between 0 and 35 based on its position in the alphabet (i.e., “A”=0, “a”=0, “B”=1, “b”=1, …, “Z”=25, “z”=25, “0”=26,”1″=27, …, “9”=35). Note that the alphabet contains letters and numbers.
  • For each character in the alphabet, where the numeric value is ?, the encoded value of the letter is defined as ?(?) = (?? + ?) % 36 where ? and ? are the values of Arg Input 1 and Arg Input 2 respectively, as in an Affine Cipher.
  • The encoded character for the input character is calculated by taking the encoded number, which is a value between 0 and 35, and translating it back into a character (again, where “A”=0, “a”=0, “B”=1, “b”=1, …, “Z”=25, “z”=25, “0”=26, “1”=27, …, “9”=35).
  • Capitalization of alphabetic characters must be inverted (i.e., all lowercase characters are transformed into upper case characters and vice versa). Numbers encoded to alphabetic characters must be lowercase.
  • All non-alphanumeric characters must remain unchanged.
  • The output should be shown using a non-editable TextView that is initially blank and (re)computed when the “Encrypt Entry Text” 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
  • Inputs:

Entry Text = “Cat & 5 DogS”

Arg Input 1 = 5

Arg Input 2 = 3

  • Output:

Text Encrypted = “nD0 & o sB7v”

  • Explanation:

○ “C” has value 2, (2 * 5 + 3) % 36 = 13, 13 corresponds to “n”. (lowercase since

“C” is capitalized)

○ “a” has value 0, (0 * 5 + 3) % 36 = 3, 3 corresponds to “D”. (capitalized because

“a” is lowercase)

○ …

○ ” “, “&”, and ” ” are unchanged

○ “5” has value 31, (31 * 5 + 3) % 36 = 14, 14 corresponds to “o”. (lowercase

since “5” is a digit)

○ ” ” is unchanged

○ …

ERROR MESSAGES

The app should generate suitable error messages by calling EditText’s setError method (inherited from TextView) on the appropriate EditText widget when the computation is triggered (i.e., the button is pressed). 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:

  1. “Invalid Entry Text”, related to the Entry Text field, for an empty or letter- or number-less entry.
  2. “Invalid Arg Input 1”, related to the Arg Input 1 field, for a blank or unacceptable value(i.e., not coprime to 36).
  1. “Invalid Arg Input 2”, related to the Arg Input 2 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.