Maurice Tutor

(5)

$15/per page/Negotiable

About Maurice Tutor

Levels Tought:
Elementary,Middle School,High School,College,University,PHD

Expertise:
Algebra,Applied Sciences See all
Algebra,Applied Sciences,Biology,Calculus,Chemistry,Economics,English,Essay writing,Geography,Geology,Health & Medical,Physics,Science Hide all
Teaching Since: May 2017
Last Sign in: 398 Weeks Ago, 5 Days Ago
Questions Answered: 66690
Tutorials Posted: 66688

Education

  • MCS,PHD
    Argosy University/ Phoniex University/
    Nov-2005 - Oct-2011

Experience

  • Professor
    Phoniex University
    Oct-2001 - Nov-2016

Category > Computer Science Posted 14 Sep 2017 My Price 8.00

File Encryption and Decryption

Python Programming Python 3

How do you use a dictionary to assign "codes" to each letter of the alphabet?

My program 2 does not write out the text correctly when decoding because the codes have duplicate characters. It does not know which character is actually the letter and it puts both.


def main():

    codes = {'A':'6', 'a':'~', 'B':'66', 'b':';', 'C':'<', 'c':'@', 'D':'%$', 'd':'#', \
'E':'5', 'e':'$', 'F':'3', 'f':'%', 'G':'71', 'g':'^', 'H':'72', 'h':'&', 'I':'4', 'i':'*', \
         'J':'74', 'j':'(', 'K':'75', 'k':')', 'L':'1', 'l':'_', 'M':'77', 'm':'`', 'N':'/:', \
         'n':'-', 'O':'79', 'o':'+', 'P':'2', 'p':'=', 'Q':'99', 'q':'9', 'R':'82', 'r':'>', 'S':'83', \
         's':'[','T':'', 't':']', 'U': ';', 'u':'{', 'V':'86', 'v':'}', 'W':'7', 'w':'/', \
         'X':'/+', 'x':'8', 'Y':'%(', 'y':'0', 'Z':'90', 'z':'$122'}

    encr_file = open('newtext.txt','r')

    file_read = encr_file.read()

    encr_file.close()

    codes_items = codes.items()

    for ch in file_read:
        if not ch in codes.values() or ch == '.':
            print(ch,end='')
        else:
            for k,v in codes_items:
                if ch == v and ch != '.':
                    print(k,end='')

main()


File Encryption and Decryption
Write a program that uses a dictionary to assign A????1codesA????1 to each letter of the alphabet. For example:
codes = { 'A' : '%', 'a' : '9', 'B' : '@', 'b' : '#', etc . . .} Using this example, the letter A would be assigned the symbol %, the letter a would be assigned the number 9, the letter B would be assigned the symbol @, and so forth.

The program should open a specified text file, read its contents, and then use the dictionary to write an encrypted version of the fileA????1s contents to a second file. Each character in the second file should contain the code for the corresponding character in the first file.

Write a second program that opens an encrypted file and displays its decrypted contents on the screen

Answers

(5)
Status NEW Posted 14 Sep 2017 10:09 PM My Price 8.00

Hel-----------lo -----------Sir-----------/Ma-----------dam-----------Tha-----------nk -----------You----------- fo-----------r u-----------sin-----------g o-----------ur -----------web-----------sit-----------e a-----------nd -----------and----------- ac-----------qui-----------sit-----------ion----------- of----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n.P-----------lea-----------se -----------pin-----------g m-----------e o-----------n c-----------hat----------- I -----------am -----------onl-----------ine----------- or----------- in-----------box----------- me----------- a -----------mes-----------sag-----------e I----------- wi-----------ll

Not Rated(0)