SlideShare a Scribd company logo
in python
in python
Secret Decoder Ring Write a program that allows the user to encrypt or decrypt messages using
different types of encryption methods. Encrypted messages will read from the console and then
written to a file called 'message.txt', and decrypted messages will be read from the 'message.txt'
file then displayed to the console. Implement the following class structure using Inheritance:
Cipher (cipher.py) - Implements the Atbash Cipher - is a substitution cipher where the encrypted
message is obtained by looking up each letter and finding the corresponding letter in a reversed
alphabet. The encoded letter can be found in one of two ways, either a parallel list look up (ex.
letter to encode = B ', location = 1 , encoded letter location = 1 , which is a a Y ), or a calculated
position in the list (ex. letter to encode = B ', location = 1 , 25 - location = 24 , encoded letter
location = 24 , which is a ' Y '). 1. _init_(self) - initializes the alphabet attribute - make a list with
the letters A- Z in it (alternatively, this could just be one big string with the letters A Z in it, since
a string is effectively a list). 2. encrypt_message(self, message) - convert the message to upper
case letters, then loop through the message string one character at a time, if it is a letter A-Z, then
call the encrypt_letter method, otherwise ignore the character. Build the encryption string using
the encrypted letters and ignored characters, and then return it (ie. leave all spaces. punctuation,
and numbers the same, only letters in the string will be encrypted). 3. decrypt_message(self,
message) - convert the message to upper case letters, then loop through the message string one
character at a time. Build the decryption string using the decrypted letters in a manner similar to
the encrypt_message method above. 4. _encrypt_letter(self, letter) - look up the letter in the
alphabet to find its location. Use that location to calculate the position of the encrypted letter in
the manner described above, then retum the encrypted letter. 5. _decrypt_letter(self, letter)-look
up the letter in the alphabet to find its location. Use that location to calculate the position of the
decrypted letter in the manner described above, then return the decrypted letter. CasesarCipher
(caesar_cipher.py) - Implements a Caesar Cipher - is another substitution cipher where the
encrypted message is found by looking up each letter and finding the corresponding letter in a
shifted alphabet (ex. letter to encode = ' B ", location = 1 , shift value = 3 , location + shift value
= 1 + 3 = 4 , encoded letter location = 4 , which is an + E ). . If the shift value causes the encoded
letter to be past the end of the alphabet, then it should wrap around to the beginning (ex. letter to
encode = ' X ', location = 23 , shift value = 3 , location + shift value = 23 + 3 = 26 , encoded
letter location = 26 , which is larger than 25 , subtract the total number of letters in the alphabet
to get the updated location, 26 26 = 0 , which is an + A ). Example alphabet with a shift value of
3 : 1. extend the cipher class 2. _init_(self, shift) - call super to initialize the alphabet, then set the
shift value if it is a number, otherwise raise an exception. 3. enerypt_letter(self. letter) - look up
the letter in the alphabet to find its location. Use that location to calculate the position of the
encrypted letter in the manner described above, then return the encrypted letter. 4.
decrypt_letter(self, letter) - look up the letter in the alphabet to find its location. Use that location
to calculate the position of the decrypted letter in the manner described above, then return the
decrypted letter. Main (main.py): Have the user choose to encrypt or decrypt a message, then
have them choose an encryption/decryption method (Atbash or Caesar cipher). If they chose to
encrypt, then prompt them to enter a message to encrypt, then write the encrypted message to the
file 'message.txt'. If they choose to decrypt a message, read the message from the file
'message.txt' and then display the decrypted message to the console. If they choose to use a
Caesar Cipher for either encryption or decryption, then prompt the user to enter a shift value ( 0 -
25). Example Output (user input is in italics): Secret Decoder Ring: 1. Encrypt 2. Decrypt Enter
shift value: 3 Encrypted message saved to "message.txt". Encrypted message written to file:
WKH VRXS LV SRLVRQHG! Secret Decoder Ring: 1. Encrypt 2. Decrypt 2 Enter decryption
type: 1. Atbash 2. Caesar 2 Enter shift value: 3 Reading encrypted message from "message.txt".
Decrypted message: THE SOUP IS POISONED! Notes: 1. You should have 4 different files:
cipher.py, caesar_cipher.py, main.py, and check_input.py. 2. Check all user input (except for the
message) for invalid values using get_int_range. 3. Do not create any extra methods or attributes
in your classes. 4. Please do not create any global variables or use the attributes globally. Only
access the attributes using the class's methods (note: it's usually ok for the subclass to access the
attributes of the superclass directly, since they are also attributes of the subclass). 5. Use
docstrings to document the classes, and each of their methods. 6. Place your names, date, and a
brief description of the program in a comment block at the top of your main file. Place brief
comments throughout your code. 7. Thoroughly test your program before submitting: a. Make
sure that the user input is validated. b. Make sure that the encrypted messages are written to the
file. c. Make sure that decrypted messages are read from the file. d. Make sure that the
encrypted/decrypted text is correct given the type of encryption/decryption and the shift value
(when caesar is used). e. Make sure that you test letters that are at the end of the alphabet so that
when caesar's shift value is applied, it does not go out of bounds of the alphabet. f. Make sure
that any spaces, punctuation, or numbers are preserved in the encrypted/decrypted message (only
letters need to be encrypted).

More Related Content

Similar to in python in python Secret Decoder Ring Write a program that allows.pdf

Python help- You will be writing an encryption program for an IT compa.pdf
Python help- You will be writing an encryption program for an IT compa.pdfPython help- You will be writing an encryption program for an IT compa.pdf
Python help- You will be writing an encryption program for an IT compa.pdf
ChristopherkUzHunter
 
Please write the program mysh in C programming language and follow.pdf
Please write the program mysh in C programming language and follow.pdfPlease write the program mysh in C programming language and follow.pdf
Please write the program mysh in C programming language and follow.pdf
amarndsons
 
Cryptography Intro - NCL
Cryptography Intro - NCLCryptography Intro - NCL
Cryptography Intro - NCL
jrice8
 
Comp 122 lab 7 lab report and source code
Comp 122 lab 7 lab report and source codeComp 122 lab 7 lab report and source code
Comp 122 lab 7 lab report and source code
pradesigali1
 
Computer Network Unit-5 (Part-1).pdf
Computer Network Unit-5 (Part-1).pdfComputer Network Unit-5 (Part-1).pdf
Computer Network Unit-5 (Part-1).pdf
ParshantYadav13
 
Objective c slide I
Objective c slide IObjective c slide I
Objective c slide I
Diksha Bhargava
 
Concept Of C++ Data Types
Concept Of C++ Data TypesConcept Of C++ Data Types
Concept Of C++ Data Types
k v
 
security system by desu star chapter 2 (1).pptx
security system by desu star chapter 2 (1).pptxsecurity system by desu star chapter 2 (1).pptx
security system by desu star chapter 2 (1).pptx
desalewminale
 
manish python.pptx
manish python.pptxmanish python.pptx
manish python.pptx
ssuser92d141
 
Secret key cryptography
Secret key cryptographySecret key cryptography
Secret key cryptography
Prabhat Goel
 
python1.ppt
python1.pptpython1.ppt
python1.ppt
ALOK52916
 
python1.ppt
python1.pptpython1.ppt
python1.ppt
VishwasKumar58
 
Python Basics
Python BasicsPython Basics
Python Basics
MobeenAhmed25
 
python1.ppt
python1.pptpython1.ppt
python1.ppt
RajPurohit33
 
Lenguaje Python
Lenguaje PythonLenguaje Python
Lenguaje Python
RalAnteloJurado
 
Learn Python in Three Hours - Presentation
Learn Python in Three Hours - PresentationLearn Python in Three Hours - Presentation
Learn Python in Three Hours - Presentation
Naseer-ul-Hassan Rehman
 
pysdasdasdsadsadsadsadsadsadasdasdthon1.ppt
pysdasdasdsadsadsadsadsadsadasdasdthon1.pptpysdasdasdsadsadsadsadsadsadasdasdthon1.ppt
pysdasdasdsadsadsadsadsadsadasdasdthon1.ppt
kashifmajeedjanjua
 
coolstuff.ppt
coolstuff.pptcoolstuff.ppt
coolstuff.ppt
GeorgePama1
 

Similar to in python in python Secret Decoder Ring Write a program that allows.pdf (20)

Python help- You will be writing an encryption program for an IT compa.pdf
Python help- You will be writing an encryption program for an IT compa.pdfPython help- You will be writing an encryption program for an IT compa.pdf
Python help- You will be writing an encryption program for an IT compa.pdf
 
Please write the program mysh in C programming language and follow.pdf
Please write the program mysh in C programming language and follow.pdfPlease write the program mysh in C programming language and follow.pdf
Please write the program mysh in C programming language and follow.pdf
 
Cryptography Intro - NCL
Cryptography Intro - NCLCryptography Intro - NCL
Cryptography Intro - NCL
 
Comp 122 lab 7 lab report and source code
Comp 122 lab 7 lab report and source codeComp 122 lab 7 lab report and source code
Comp 122 lab 7 lab report and source code
 
LectureNotes-04-DSA
LectureNotes-04-DSALectureNotes-04-DSA
LectureNotes-04-DSA
 
Computer Network Unit-5 (Part-1).pdf
Computer Network Unit-5 (Part-1).pdfComputer Network Unit-5 (Part-1).pdf
Computer Network Unit-5 (Part-1).pdf
 
Objective c slide I
Objective c slide IObjective c slide I
Objective c slide I
 
ENGLISH PYTHON.ppt
ENGLISH PYTHON.pptENGLISH PYTHON.ppt
ENGLISH PYTHON.ppt
 
Concept Of C++ Data Types
Concept Of C++ Data TypesConcept Of C++ Data Types
Concept Of C++ Data Types
 
security system by desu star chapter 2 (1).pptx
security system by desu star chapter 2 (1).pptxsecurity system by desu star chapter 2 (1).pptx
security system by desu star chapter 2 (1).pptx
 
manish python.pptx
manish python.pptxmanish python.pptx
manish python.pptx
 
Secret key cryptography
Secret key cryptographySecret key cryptography
Secret key cryptography
 
python1.ppt
python1.pptpython1.ppt
python1.ppt
 
python1.ppt
python1.pptpython1.ppt
python1.ppt
 
Python Basics
Python BasicsPython Basics
Python Basics
 
python1.ppt
python1.pptpython1.ppt
python1.ppt
 
Lenguaje Python
Lenguaje PythonLenguaje Python
Lenguaje Python
 
Learn Python in Three Hours - Presentation
Learn Python in Three Hours - PresentationLearn Python in Three Hours - Presentation
Learn Python in Three Hours - Presentation
 
pysdasdasdsadsadsadsadsadsadasdasdthon1.ppt
pysdasdasdsadsadsadsadsadsadasdasdthon1.pptpysdasdasdsadsadsadsadsadsadasdasdthon1.ppt
pysdasdasdsadsadsadsadsadsadasdasdthon1.ppt
 
coolstuff.ppt
coolstuff.pptcoolstuff.ppt
coolstuff.ppt
 

More from asdepartmantal

In eukaryotes- the TCA cycle reactions take place in whereas glycolysi.pdf
In eukaryotes- the TCA cycle reactions take place in whereas glycolysi.pdfIn eukaryotes- the TCA cycle reactions take place in whereas glycolysi.pdf
In eukaryotes- the TCA cycle reactions take place in whereas glycolysi.pdf
asdepartmantal
 
In December- the first five transactions of Anders' Maid Service Compa.pdf
In December- the first five transactions of Anders' Maid Service Compa.pdfIn December- the first five transactions of Anders' Maid Service Compa.pdf
In December- the first five transactions of Anders' Maid Service Compa.pdf
asdepartmantal
 
In class- we discussed microcredit- Do some research online and briefl.pdf
In class- we discussed microcredit- Do some research online and briefl.pdfIn class- we discussed microcredit- Do some research online and briefl.pdf
In class- we discussed microcredit- Do some research online and briefl.pdf
asdepartmantal
 
In cell D1- insert a screenshot of the MS Word file titled PB Newslett.pdf
In cell D1- insert a screenshot of the MS Word file titled PB Newslett.pdfIn cell D1- insert a screenshot of the MS Word file titled PB Newslett.pdf
In cell D1- insert a screenshot of the MS Word file titled PB Newslett.pdf
asdepartmantal
 
In C4 plants- RuBisCO is protected from binding to Oxygen by--- Multip.pdf
In C4 plants- RuBisCO is protected from binding to Oxygen by--- Multip.pdfIn C4 plants- RuBisCO is protected from binding to Oxygen by--- Multip.pdf
In C4 plants- RuBisCO is protected from binding to Oxygen by--- Multip.pdf
asdepartmantal
 
In Aplysia long-term facilitation (long-term memory)- the transcriptio.pdf
In Aplysia long-term facilitation (long-term memory)- the transcriptio.pdfIn Aplysia long-term facilitation (long-term memory)- the transcriptio.pdf
In Aplysia long-term facilitation (long-term memory)- the transcriptio.pdf
asdepartmantal
 
In August 2012- tropical storm Isaac formed in the Caribbean and was h.pdf
In August 2012- tropical storm Isaac formed in the Caribbean and was h.pdfIn August 2012- tropical storm Isaac formed in the Caribbean and was h.pdf
In August 2012- tropical storm Isaac formed in the Caribbean and was h.pdf
asdepartmantal
 
In Aplysia- (short-term) sensitization involves activation of- PKA and.pdf
In Aplysia- (short-term) sensitization involves activation of- PKA and.pdfIn Aplysia- (short-term) sensitization involves activation of- PKA and.pdf
In Aplysia- (short-term) sensitization involves activation of- PKA and.pdf
asdepartmantal
 
In Birmingham- Richard Smith lives with his wife- Catherine Frossard-.pdf
In Birmingham- Richard Smith lives with his wife- Catherine Frossard-.pdfIn Birmingham- Richard Smith lives with his wife- Catherine Frossard-.pdf
In Birmingham- Richard Smith lives with his wife- Catherine Frossard-.pdf
asdepartmantal
 
IN C++ PLEASE Topics Loops While statement Description Write.pdf
IN C++ PLEASE     Topics   Loops While statement   Description   Write.pdfIN C++ PLEASE     Topics   Loops While statement   Description   Write.pdf
IN C++ PLEASE Topics Loops While statement Description Write.pdf
asdepartmantal
 
In C code- Write a program with 2 children process- where one child is.pdf
In C code- Write a program with 2 children process- where one child is.pdfIn C code- Write a program with 2 children process- where one child is.pdf
In C code- Write a program with 2 children process- where one child is.pdf
asdepartmantal
 
In Aplysia long-term facilitation (sensitization)- CREB 1 increases an.pdf
In Aplysia long-term facilitation (sensitization)- CREB 1 increases an.pdfIn Aplysia long-term facilitation (sensitization)- CREB 1 increases an.pdf
In Aplysia long-term facilitation (sensitization)- CREB 1 increases an.pdf
asdepartmantal
 
in python please Implement and test a heapSort function that uses hea.pdf
in python please  Implement and test a heapSort function that uses hea.pdfin python please  Implement and test a heapSort function that uses hea.pdf
in python please Implement and test a heapSort function that uses hea.pdf
asdepartmantal
 
In Python - Modify the postfix eval algorithm code below so it handles.pdf
In Python - Modify the postfix eval algorithm code below so it handles.pdfIn Python - Modify the postfix eval algorithm code below so it handles.pdf
In Python - Modify the postfix eval algorithm code below so it handles.pdf
asdepartmantal
 
in python Utilize the functions of the graphics-py module ( https---yo.pdf
in python Utilize the functions of the graphics-py module ( https---yo.pdfin python Utilize the functions of the graphics-py module ( https---yo.pdf
in python Utilize the functions of the graphics-py module ( https---yo.pdf
asdepartmantal
 
in python Define a function named swap_values that takes four integer.pdf
in python  Define a function named swap_values that takes four integer.pdfin python  Define a function named swap_values that takes four integer.pdf
in python Define a function named swap_values that takes four integer.pdf
asdepartmantal
 
in presenting data that resulied from an experiment- a group of staden.pdf
in presenting data that resulied from an experiment- a group of staden.pdfin presenting data that resulied from an experiment- a group of staden.pdf
in presenting data that resulied from an experiment- a group of staden.pdf
asdepartmantal
 
In order to perform a one-way ANOVA test- there are three basic assump.pdf
In order to perform a one-way ANOVA test- there are three basic assump.pdfIn order to perform a one-way ANOVA test- there are three basic assump.pdf
In order to perform a one-way ANOVA test- there are three basic assump.pdf
asdepartmantal
 
In order to see the contents of a given variable- mydata the following.pdf
In order to see the contents of a given variable- mydata the following.pdfIn order to see the contents of a given variable- mydata the following.pdf
In order to see the contents of a given variable- mydata the following.pdf
asdepartmantal
 
In addition to cost- what major qualitative factors should Zara consid.pdf
In addition to cost- what major qualitative factors should Zara consid.pdfIn addition to cost- what major qualitative factors should Zara consid.pdf
In addition to cost- what major qualitative factors should Zara consid.pdf
asdepartmantal
 

More from asdepartmantal (20)

In eukaryotes- the TCA cycle reactions take place in whereas glycolysi.pdf
In eukaryotes- the TCA cycle reactions take place in whereas glycolysi.pdfIn eukaryotes- the TCA cycle reactions take place in whereas glycolysi.pdf
In eukaryotes- the TCA cycle reactions take place in whereas glycolysi.pdf
 
In December- the first five transactions of Anders' Maid Service Compa.pdf
In December- the first five transactions of Anders' Maid Service Compa.pdfIn December- the first five transactions of Anders' Maid Service Compa.pdf
In December- the first five transactions of Anders' Maid Service Compa.pdf
 
In class- we discussed microcredit- Do some research online and briefl.pdf
In class- we discussed microcredit- Do some research online and briefl.pdfIn class- we discussed microcredit- Do some research online and briefl.pdf
In class- we discussed microcredit- Do some research online and briefl.pdf
 
In cell D1- insert a screenshot of the MS Word file titled PB Newslett.pdf
In cell D1- insert a screenshot of the MS Word file titled PB Newslett.pdfIn cell D1- insert a screenshot of the MS Word file titled PB Newslett.pdf
In cell D1- insert a screenshot of the MS Word file titled PB Newslett.pdf
 
In C4 plants- RuBisCO is protected from binding to Oxygen by--- Multip.pdf
In C4 plants- RuBisCO is protected from binding to Oxygen by--- Multip.pdfIn C4 plants- RuBisCO is protected from binding to Oxygen by--- Multip.pdf
In C4 plants- RuBisCO is protected from binding to Oxygen by--- Multip.pdf
 
In Aplysia long-term facilitation (long-term memory)- the transcriptio.pdf
In Aplysia long-term facilitation (long-term memory)- the transcriptio.pdfIn Aplysia long-term facilitation (long-term memory)- the transcriptio.pdf
In Aplysia long-term facilitation (long-term memory)- the transcriptio.pdf
 
In August 2012- tropical storm Isaac formed in the Caribbean and was h.pdf
In August 2012- tropical storm Isaac formed in the Caribbean and was h.pdfIn August 2012- tropical storm Isaac formed in the Caribbean and was h.pdf
In August 2012- tropical storm Isaac formed in the Caribbean and was h.pdf
 
In Aplysia- (short-term) sensitization involves activation of- PKA and.pdf
In Aplysia- (short-term) sensitization involves activation of- PKA and.pdfIn Aplysia- (short-term) sensitization involves activation of- PKA and.pdf
In Aplysia- (short-term) sensitization involves activation of- PKA and.pdf
 
In Birmingham- Richard Smith lives with his wife- Catherine Frossard-.pdf
In Birmingham- Richard Smith lives with his wife- Catherine Frossard-.pdfIn Birmingham- Richard Smith lives with his wife- Catherine Frossard-.pdf
In Birmingham- Richard Smith lives with his wife- Catherine Frossard-.pdf
 
IN C++ PLEASE Topics Loops While statement Description Write.pdf
IN C++ PLEASE     Topics   Loops While statement   Description   Write.pdfIN C++ PLEASE     Topics   Loops While statement   Description   Write.pdf
IN C++ PLEASE Topics Loops While statement Description Write.pdf
 
In C code- Write a program with 2 children process- where one child is.pdf
In C code- Write a program with 2 children process- where one child is.pdfIn C code- Write a program with 2 children process- where one child is.pdf
In C code- Write a program with 2 children process- where one child is.pdf
 
In Aplysia long-term facilitation (sensitization)- CREB 1 increases an.pdf
In Aplysia long-term facilitation (sensitization)- CREB 1 increases an.pdfIn Aplysia long-term facilitation (sensitization)- CREB 1 increases an.pdf
In Aplysia long-term facilitation (sensitization)- CREB 1 increases an.pdf
 
in python please Implement and test a heapSort function that uses hea.pdf
in python please  Implement and test a heapSort function that uses hea.pdfin python please  Implement and test a heapSort function that uses hea.pdf
in python please Implement and test a heapSort function that uses hea.pdf
 
In Python - Modify the postfix eval algorithm code below so it handles.pdf
In Python - Modify the postfix eval algorithm code below so it handles.pdfIn Python - Modify the postfix eval algorithm code below so it handles.pdf
In Python - Modify the postfix eval algorithm code below so it handles.pdf
 
in python Utilize the functions of the graphics-py module ( https---yo.pdf
in python Utilize the functions of the graphics-py module ( https---yo.pdfin python Utilize the functions of the graphics-py module ( https---yo.pdf
in python Utilize the functions of the graphics-py module ( https---yo.pdf
 
in python Define a function named swap_values that takes four integer.pdf
in python  Define a function named swap_values that takes four integer.pdfin python  Define a function named swap_values that takes four integer.pdf
in python Define a function named swap_values that takes four integer.pdf
 
in presenting data that resulied from an experiment- a group of staden.pdf
in presenting data that resulied from an experiment- a group of staden.pdfin presenting data that resulied from an experiment- a group of staden.pdf
in presenting data that resulied from an experiment- a group of staden.pdf
 
In order to perform a one-way ANOVA test- there are three basic assump.pdf
In order to perform a one-way ANOVA test- there are three basic assump.pdfIn order to perform a one-way ANOVA test- there are three basic assump.pdf
In order to perform a one-way ANOVA test- there are three basic assump.pdf
 
In order to see the contents of a given variable- mydata the following.pdf
In order to see the contents of a given variable- mydata the following.pdfIn order to see the contents of a given variable- mydata the following.pdf
In order to see the contents of a given variable- mydata the following.pdf
 
In addition to cost- what major qualitative factors should Zara consid.pdf
In addition to cost- what major qualitative factors should Zara consid.pdfIn addition to cost- what major qualitative factors should Zara consid.pdf
In addition to cost- what major qualitative factors should Zara consid.pdf
 

Recently uploaded

Chapter -12, Antibiotics (One Page Notes).pdf
Chapter -12, Antibiotics (One Page Notes).pdfChapter -12, Antibiotics (One Page Notes).pdf
Chapter -12, Antibiotics (One Page Notes).pdf
Kartik Tiwari
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
Delapenabediema
 
Multithreading_in_C++ - std::thread, race condition
Multithreading_in_C++ - std::thread, race conditionMultithreading_in_C++ - std::thread, race condition
Multithreading_in_C++ - std::thread, race condition
Mohammed Sikander
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
Pavel ( NSTU)
 
Pride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School DistrictPride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School District
David Douglas School District
 
The Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptxThe Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptx
DhatriParmar
 
Guidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th SemesterGuidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th Semester
Atul Kumar Singh
 
MASS MEDIA STUDIES-835-CLASS XI Resource Material.pdf
MASS MEDIA STUDIES-835-CLASS XI Resource Material.pdfMASS MEDIA STUDIES-835-CLASS XI Resource Material.pdf
MASS MEDIA STUDIES-835-CLASS XI Resource Material.pdf
goswamiyash170123
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
Vikramjit Singh
 
Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.
Ashokrao Mane college of Pharmacy Peth-Vadgaon
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
EverAndrsGuerraGuerr
 
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBCSTRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
kimdan468
 
A Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptxA Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptx
thanhdowork
 
Acetabularia Information For Class 9 .docx
Acetabularia Information For Class 9  .docxAcetabularia Information For Class 9  .docx
Acetabularia Information For Class 9 .docx
vaibhavrinwa19
 
Advantages and Disadvantages of CMS from an SEO Perspective
Advantages and Disadvantages of CMS from an SEO PerspectiveAdvantages and Disadvantages of CMS from an SEO Perspective
Advantages and Disadvantages of CMS from an SEO Perspective
Krisztián Száraz
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
JosvitaDsouza2
 
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
Nguyen Thanh Tu Collection
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
Special education needs
 
"Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe..."Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe...
SACHIN R KONDAGURI
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
MysoreMuleSoftMeetup
 

Recently uploaded (20)

Chapter -12, Antibiotics (One Page Notes).pdf
Chapter -12, Antibiotics (One Page Notes).pdfChapter -12, Antibiotics (One Page Notes).pdf
Chapter -12, Antibiotics (One Page Notes).pdf
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
 
Multithreading_in_C++ - std::thread, race condition
Multithreading_in_C++ - std::thread, race conditionMultithreading_in_C++ - std::thread, race condition
Multithreading_in_C++ - std::thread, race condition
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
 
Pride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School DistrictPride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School District
 
The Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptxThe Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptx
 
Guidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th SemesterGuidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th Semester
 
MASS MEDIA STUDIES-835-CLASS XI Resource Material.pdf
MASS MEDIA STUDIES-835-CLASS XI Resource Material.pdfMASS MEDIA STUDIES-835-CLASS XI Resource Material.pdf
MASS MEDIA STUDIES-835-CLASS XI Resource Material.pdf
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
 
Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
 
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBCSTRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
 
A Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptxA Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptx
 
Acetabularia Information For Class 9 .docx
Acetabularia Information For Class 9  .docxAcetabularia Information For Class 9  .docx
Acetabularia Information For Class 9 .docx
 
Advantages and Disadvantages of CMS from an SEO Perspective
Advantages and Disadvantages of CMS from an SEO PerspectiveAdvantages and Disadvantages of CMS from an SEO Perspective
Advantages and Disadvantages of CMS from an SEO Perspective
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
 
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
 
"Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe..."Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe...
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
 

in python in python Secret Decoder Ring Write a program that allows.pdf

  • 1. in python in python Secret Decoder Ring Write a program that allows the user to encrypt or decrypt messages using different types of encryption methods. Encrypted messages will read from the console and then written to a file called 'message.txt', and decrypted messages will be read from the 'message.txt' file then displayed to the console. Implement the following class structure using Inheritance: Cipher (cipher.py) - Implements the Atbash Cipher - is a substitution cipher where the encrypted message is obtained by looking up each letter and finding the corresponding letter in a reversed alphabet. The encoded letter can be found in one of two ways, either a parallel list look up (ex. letter to encode = B ', location = 1 , encoded letter location = 1 , which is a a Y ), or a calculated position in the list (ex. letter to encode = B ', location = 1 , 25 - location = 24 , encoded letter location = 24 , which is a ' Y '). 1. _init_(self) - initializes the alphabet attribute - make a list with the letters A- Z in it (alternatively, this could just be one big string with the letters A Z in it, since a string is effectively a list). 2. encrypt_message(self, message) - convert the message to upper case letters, then loop through the message string one character at a time, if it is a letter A-Z, then call the encrypt_letter method, otherwise ignore the character. Build the encryption string using the encrypted letters and ignored characters, and then return it (ie. leave all spaces. punctuation, and numbers the same, only letters in the string will be encrypted). 3. decrypt_message(self, message) - convert the message to upper case letters, then loop through the message string one character at a time. Build the decryption string using the decrypted letters in a manner similar to the encrypt_message method above. 4. _encrypt_letter(self, letter) - look up the letter in the alphabet to find its location. Use that location to calculate the position of the encrypted letter in the manner described above, then retum the encrypted letter. 5. _decrypt_letter(self, letter)-look up the letter in the alphabet to find its location. Use that location to calculate the position of the decrypted letter in the manner described above, then return the decrypted letter. CasesarCipher (caesar_cipher.py) - Implements a Caesar Cipher - is another substitution cipher where the encrypted message is found by looking up each letter and finding the corresponding letter in a shifted alphabet (ex. letter to encode = ' B ", location = 1 , shift value = 3 , location + shift value = 1 + 3 = 4 , encoded letter location = 4 , which is an + E ). . If the shift value causes the encoded letter to be past the end of the alphabet, then it should wrap around to the beginning (ex. letter to encode = ' X ', location = 23 , shift value = 3 , location + shift value = 23 + 3 = 26 , encoded letter location = 26 , which is larger than 25 , subtract the total number of letters in the alphabet to get the updated location, 26 26 = 0 , which is an + A ). Example alphabet with a shift value of 3 : 1. extend the cipher class 2. _init_(self, shift) - call super to initialize the alphabet, then set the shift value if it is a number, otherwise raise an exception. 3. enerypt_letter(self. letter) - look up the letter in the alphabet to find its location. Use that location to calculate the position of the encrypted letter in the manner described above, then return the encrypted letter. 4. decrypt_letter(self, letter) - look up the letter in the alphabet to find its location. Use that location to calculate the position of the decrypted letter in the manner described above, then return the decrypted letter. Main (main.py): Have the user choose to encrypt or decrypt a message, then have them choose an encryption/decryption method (Atbash or Caesar cipher). If they chose to encrypt, then prompt them to enter a message to encrypt, then write the encrypted message to the file 'message.txt'. If they choose to decrypt a message, read the message from the file 'message.txt' and then display the decrypted message to the console. If they choose to use a Caesar Cipher for either encryption or decryption, then prompt the user to enter a shift value ( 0 - 25). Example Output (user input is in italics): Secret Decoder Ring: 1. Encrypt 2. Decrypt Enter
  • 2. shift value: 3 Encrypted message saved to "message.txt". Encrypted message written to file: WKH VRXS LV SRLVRQHG! Secret Decoder Ring: 1. Encrypt 2. Decrypt 2 Enter decryption type: 1. Atbash 2. Caesar 2 Enter shift value: 3 Reading encrypted message from "message.txt". Decrypted message: THE SOUP IS POISONED! Notes: 1. You should have 4 different files: cipher.py, caesar_cipher.py, main.py, and check_input.py. 2. Check all user input (except for the message) for invalid values using get_int_range. 3. Do not create any extra methods or attributes in your classes. 4. Please do not create any global variables or use the attributes globally. Only access the attributes using the class's methods (note: it's usually ok for the subclass to access the attributes of the superclass directly, since they are also attributes of the subclass). 5. Use docstrings to document the classes, and each of their methods. 6. Place your names, date, and a brief description of the program in a comment block at the top of your main file. Place brief comments throughout your code. 7. Thoroughly test your program before submitting: a. Make sure that the user input is validated. b. Make sure that the encrypted messages are written to the file. c. Make sure that decrypted messages are read from the file. d. Make sure that the encrypted/decrypted text is correct given the type of encryption/decryption and the shift value (when caesar is used). e. Make sure that you test letters that are at the end of the alphabet so that when caesar's shift value is applied, it does not go out of bounds of the alphabet. f. Make sure that any spaces, punctuation, or numbers are preserved in the encrypted/decrypted message (only letters need to be encrypted).