Instructions

Use the strategy of the decimal to binary conversion implemented in Project 4.4, and the bit shift left operation defined in Project 4.5 to code a new encryption algorithm.

The algorithm should

  • Add 1 to each character’s numeric ASCII value.
  • Convert it to a bit string.
  • Shift the bits of this string one place to the left.

A single-space character in the encrypted string separates the resulting bit strings.

An example of the program input and output is shown below:

Enter a message: Hello world!

0010011 1001101 1011011 1011011 1100001 000011 1110001 1100001 1100111 1011011 1001011 000101

Flowchart

To enlarge flowchart turn side navigation off, Click on Side Navigation button on in the top navigation bar to change to Side Navigation button off

Flowchart
Flowchart

Starter Code

"""
File: encrypt.py
Probject 4.6

Encypts an input string of characters and prints
the result.
"""

# Prompt user to enter a message

# Initialize variable to store encrypted text

# iterate

    # Add 1 to ASCII value

    # Convert to binary



    # Shift one bit to left

    # Add encrypted character to code string
    
Tags: