Answered You can buy a ready-made answer or pick a professional tutor to order an original one.

QUESTION

Suppose you want to send a message to a friend, however you want to ensure that the

Problem Description:==================Suppose you want to send a message to a friend, however you want to ensure that themessage remains private and no one can intercept and read it. To scramble the message in away that it can only be decoded by your friend is called ciphering/deciphering and is a part ofcryptography. In Lab-3, you need to write two cryptography functions:• cipher() – this function will encode a string using a second string as a key• decipher() – this function decodes the string using a second string as a keyTO DO #1: The cipher() function===========================Write a function named "cipher" that accepts 2 strings and returns a string. The first string (the“message string”) is the text message you’re sending and the second string (the “key string”) willbe used to encode it. Write this function assuming you are converting all text to upper case andthat we are only encoding the characters A through Z plus any spaces in the text.Assume that numbers 0 to 26 are used to represent a space as well as the 26 American alphabetcharacters. Any spaces will be represented by the number 0, while the character “A” will berepresented by the number 1 (B will be 2, C will be 3 and so on). The cipher is accomplished byadding the values of the corresponding characters from the message and key strings to determinethe encoded character. If the message string is “PURDUE” and the key string is “LIME”,1. Start with the “P” from the message and the “L” from the key2. “P” is represented by the number 16 and “L” is 12.3. 16 + 12 = 284. If the result is greater than 26, (ie: 28 in this case) subtract 265. 2 represents “B” in our cipher, so a “B” would be the first encoded characterFollow the same procedure with each character from the message and key strings. Eventually,you will have used all the key string’s characters, so you’ll need to go back to the first character ofthe key string again. Your function should continue to rotate through the characters of the keystring as many times as necessary until the entire message string is encrypted.Message Key EncryptedP L ! BU I ! DR M ! ED E ! IU L ! GE I ! NThe cipher() function should return the completely encrypted string so that enteringcipher(“PURDUE”, “LIME”) would return the string ‘BDEIGN’.TO DO #2: The decipher() function=============================Write a function named "decipher" that accepts 2 strings (the “cipher string” and the “key string”)and then returns a string. This function reverses the encoding process used in the cipher()function, so you must again assume that numbers 0 to 26 are used to represent a space and thealphabetic characters “A” through “Z”. The decoding process is accomplished by subtracting thevalues of the corresponding characters of the cipher message and the key.Assume the cipher string is “BDEIGN” and the key string is “LIME”1. Start with the “B” from the cipher string and the “L” from the key string2. “B” is represented by the number 2 and “L” is 12.3. 2 - 12 = -104. If the result is less than 0, (ie: -10 in this case), add 265. 16 represents “P” in our cipher, so a “P” would be the first decoded characterFollow the same procedure with each character from the message and key strings. Eventually,you will have used all the key string’s characters, so you’ll need to go back to the first character ofthe key string again. Your function should continue to rotate through the characters of the keystring as many times as necessary until the entire message string is encrypted.The decipher() function should return the completely encrypted string so that enteringdecipher(“BDEIGN”, “LIME”) would return the string ‘PURDUE’.SAMPLE CIPHER/DECIPHER OUTPUT================================>>> cipher(“PYTHON”, “BOY”)‘RNSJDM’>>> cipher(“TURN DOWN”, “FOR WHAT”)‘ JJNWLPQT’ ! note: first resulting character is a space>>> decipher(“RNSJDM”, “BOY”)‘PYTHON’>>>!decipher("RXIUOEQAASCP RLBSYT NKNOUHLOSX", "LINCOLN")'FOUR SCORE AND SEVEN YEARS AGO’LAB 3 GRADING RUBRIC PointsTODO #1: The cipher() function accepts 2 parameters 2TODO #1: cipher() properly encodes each character based on the key 8TODO #2: The decipher() function accepts 2 parameters 2TODO #2: decipher() properly decodes each character based on the key 8Total Points 20

Show more
  • @
  • 1 order completed
ANSWER

Tutor has posted answer for $60.00. See answer's preview

$60.00

*** getIndex(char): #function for ******* **** to index ** ** chars=[' *************************************************************************************** ****** ******************* *************** #function ** ****** ***** to **** chars=[' ''A''B''C''D''C''D''E''F''G''H''I''J''K''L''M''N''O''P''Q''R''S''T''U''V''W''X''Y''Z']; ****** *************** ******************* #cipher ******** ******** ******** i=0 *** ***** ****************** #repeat until *** of ******* ******************************************** ********* with key **** ***************** #if *** ** ***** ** **************** ********* *************************** **** equalent ****** **** ***** ******** ij ***** **************** #if * ******* to ****** ** key j=0 ***** reset to ****** ***** #return ****** ******* ********************* #decipher function ptext="" ****** **** ******** ij=00 ***** ****************** ***** ****** ** ******* ******************************************** ********* value **************** *** ***** ** ******** **************** **** **** 26 ***** *************************** **** that ********* ***** ***** if(j==len(key)): j=0 return ****************** ** * ************************************ **** ** * ****************************

Click here to download attached files: cipher.zip
or Buy custom answer
LEARN MORE EFFECTIVELY AND GET BETTER GRADES!
Ask a Question