程序代写案例-CIS 330
CIS 330 Assignments Encryp!on 101!
Total Points: 40
Encryp!on 101
Due Wednesday by 11:59pm Points 40 Available Feb 17 at 4pm - Feb 24 at 11:59pm 7 days
Rubric
Criteria Ra!ngs Pts
10 pts
10 pts
6 pts
14 pts
0. READ THE INSTRUCTIONS BELOW COMPLETELY AND CAREFULLY BEFORE PROCEEDING.
0.1 THE CLASS LECTURE ON ENCRYPTION HAS MORE DETAILS ON HOW THE CIPHERS WORK. READ IT
BEFORE PROCEEDING.

INTRODUCTION
1. In this assignment, you will be implemen!ng a program that encrypts and decrypts using several different
ciphers, as discussed in class. The ciphers are
a) subs!tu!on cipher,
b) Caesar cipher,
c) ROT13 cipher,
d) Running Key cipher, and
e) Vigenere cipher.
2. Do not change the provided skeleton code. You may add new code to the provided files, but the exis!ng code
MUST NOT BE CHANGED. In par!cular, the main.cc func!on should not be changed AT ALL (i.e., do not
change or add new code), since it will be used to test your implementa!on. Your code must conform to the way
it is used in main.cc.

REQUIREMENTS:
3. Subs!tu!on cipher (implemented in cipher.h and cipher.cc) class has already been defined (but not
implemented) for you. The other cipher classes MUST
a) inherit from the subs!tu!on cipher, or
b) inherit from one of the four other cipher classes (e.g., Caesar inherits from Subs!tu!on, ROT13 inherits from
Caesar).
4. Each new cipher class MUST have a constructor, a default constructor (except the ROT13 cipher, as
described below), and a destructor .
a) Each constructor should accept the input appropriate for the cipher:
i) subs!tu!on - cipher alphabet - must contain every le"er in the alphabet, and only once, and they must all
be lower case. It should contain no other characters (e.g., no space, punctua!on, etc.). Cipher alphabet length
should always be 26.
ii) Caesar - posi!ve shi#/rota!on/offset integer. This value can be larger than 26, in which case it has
rotated completely one or more !mes.
iii) ROT13 - no input required for constructor (see default constructor below).
iv) Running Key - a vector of strings. The vector represents the cipher "book," and each element in the vector
is a "page" from the book. Each page should be a non-empty string. This string should consist of only lower case
le"er or spaces.
v) Vigenere - a string represen!ng the key word. The key word should consist of only lower case le"ers.
b) Each default constructor should not accept any inputs.
i) ROT13: ROT13 should only have a default constructor, and it should func!on properly as a ROT13 cipher
with the default constructor.
ii) Other ciphers: default constructor should ini!alize the object so that encryp!ng any plain text should
return a cipher text that is iden!cal to the plain text. For example, for Caesar, se#ng the shi$ to 0 will achieve
this. YOU CANNOT SIMPLY RETURN THE PLAIN TEXT - IT MUST STILL ENCRYPT THE TEXT using the proper
method.
b) the destructor should free all memory. Valgrind will be used to make sure there are no memory leaks.
5. Each cipher must also provide encrypt and decrypt func!ons. They can either be implemented explicitly, or
implicitly using inheritance. This is a design decision, but the decision should be made to minimize/modularize
your code.
i) Encrypt: Assume that the input plain text will always be a) lower case le"er, b) upper case le"er, or c) a
space. Space should not be encrypted (i.e., if the plain text is "hello world", the encrypted text should look
something like "abcde fghij". Upper case le%er should be encrypted to an upper case le%er (you don't have to,
but you will find that mee!ng the decrypt requirement below will be difficult otherwise).
ii) Decrypt: This should take in the encrypted text and return the origin plain text. It should
a) retain the case (i.e., if the input plain text has an upper case le%er, the decrypted plain text should have
that le%er as upper case.
b) retain the space - If the plain text had spaces, the decrypted text should s!ll have those spaces in the
correct place.
6. Data members in all cipher classes should be hidden using the Cheshire smile.
7. Each cipher should also check to make sure that the provided cipher alphabet, rota!on etc. meets the
requirements before ini!alizing the object with it. For example, see the is_valid_alpha func!on in cipher.cc for
the subs!tu!on cipher. Below shows just A COUPLE OF EXAMPLES.
a) For the Running key cipher, each "page" of the book should be a non-empty string. If it is not, exit with
EXIT_FAILURE.
b) When encryp!ng with Running Key, make sure the key (not coun!ng the spaces) is longer than or equal to
the text you are trying to encrypt (not coun!ng the spaces). If it is not, exit with EXIT_FAILURE. .


TESTING:
8. A$er implemen!ng your code, test it against the provided test files. For example, by execu!ng:
./cipher -m c -i caesar.txt -o caesar_out.txt
a) In the above example, '-m c' means you are using the Caesar cipher method.
b) '-i caesar.txt' specifies that caesar.txt is the input file and it should contain the shi$ distance in the first line,
and the plain text you want to encrypt in the second line.
c) '-o caesar_out.txt' specifies that caesar_out.txt is the output file and it should contain the cipher text (text
a$er encryp!on) in the first line, and the decrypted text in the second line.
d) The program will also generate def_caesar_out.txt which contains the cipher text and decrypted text when
the Caesar cipher object was created using the default constructor (i.e., encryp!on is done using 0 shi$).
9. See test3_error directory to see examples of errors. In those cases, the code exited with EXIT_FAILURE, so no
output file was generated. The output to the console (i.e., cout or cerr) is shown. In your code, make sure you
generate the same error message when it exits with EXIT_FAILURE.

GRADING:
10. For this homework, some points will also be assigned depending on how well the code uses inheritance and
polymorphism to minimize/modularize the code (see the rubric).
11. Do the homework in your own repo, commit, and push to Bitbucket. If you do not push to Bitbucket, the TA
and I cannot see the code, and it will be considered a late assignment (i.e., not graded).
12. Due to the open-ended nature of this homework, there may be many ques!ons. So a) start early, and b) post
any ques!ons about the ciphers' func!onality (or any other ques!on regarding the homework) in the
Discussions sec!on on Canvas.

Op!onal Reading:
11. The code uses a library (getopt.h) for reading op!onal parameters. Read the code and the tutorial
(h%ps://azrael.digipen.edu/~mmead/www/Courses/CS180/getopt.html ) to get an understanding of how it
works. You may find this feature useful in the future.

Test Input 1
1 point for each correct cipher implemented.
10 pts
Full
Marks
0 pts
No
Marks
Test Input 2
1 point for each correct cipher implemented.
10 pts
Full
Marks
0 pts
No
Marks
Comments, Readability, and Understandability 6 pts
Full
Marks
0 pts
No
Marks
Overall program design
You will also be graded on how the program was designed - i.e., how well it uses inheritance
and polymorphism to modularize your code
14 pts
Full
Marks
0 pts
No
Marks
Winter 2021
Home
Announcements
Assignments
Discussions
Grades
People
Files
Syllabus
Quizzes
Conferences
Chat
Library Research
Help
Panopto Recordings
Zoom Mee!ngs
Account
Dashboard
Courses
Calendar
Inbox
History
Help

欢迎咨询51作业君
51作业君 51作业君

Email:51zuoyejun

@gmail.com

添加客服微信: ITCSdaixie