Question

Programming Exercise 4.6

Use the strategy of the decimal to binary conversion and the bit shift left operation defined in Project 5

bits = input("Enter bit string: ")
bits = bits[1:] + bits[0]
print ("Result:", bits) 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 

Programming Exercise 4.6 Instructions Use the strategy of the decimal to binary conversion and the bit shift left operation defined in Project 5 to code a new encryption algorithm. The algorithm should to each characters numeric . Add 1 ASCII value. 2. Convert it to a bit string. 3. 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 nessage: Hello world!

0 0
Add a comment Improve this question Transcribed image text
Answer #1

CODE IN PYTHON:

#converting int to binary
def binary_string(num):
    bit_strng="{0:b}".format(num);
    return bit_strng

#taking string as input from the user
str=input("Enter a string:")
bit_list=[]
for i in str:
    bits=binary_string(ord(i)+1)
    bits=bits[1:]+bits[0]
    bit_list.append(bits)
output=""
#displaying result
for bit in bit_list:
    output+=bit+" "
print(output)
  


OUTPUT:

Enter a string: Hello world!

Add a comment
Know the answer?
Add Answer to:
Programming Exercise 4.6 Use the strategy of the decimal to binary conversion and the bit shift...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • python Programming Exercise 4.7 Write a script that decrypts a message coded by the method used...

    python Programming Exercise 4.7 Write a script that decrypts a message coded by the method used in Project 6. Method used in project 6: 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 the coded text: 0010011 1001101 1011011 1011011...

  • 1. You are given a C file which contains a partially completed program. Follow the instructions...

    1. You are given a C file which contains a partially completed program. Follow the instructions contained in comments and complete the required functions. You will be rewriting four functions from HW03 (initializeStrings, printStrings, encryptStrings, decryptStrings) using only pointer operations instead of using array operations. In addition to this, you will be writing two new functions (printReversedString, isValidPassword). You should not be using any array operations in any of functions for this assignment. You may use only the strlen() function...

  • I NEED HELP WITH DEBUGGING A C PROGRAM! PLEASE HEAR ME OUT AND READ THIS. I...

    I NEED HELP WITH DEBUGGING A C PROGRAM! PLEASE HEAR ME OUT AND READ THIS. I just have to explain a lot so you understand how the program should work. In C programming, write a simple program to take a text file as input and encrypt/decrypt it by reading the text bit by bit, and swap the bits if it is specified by the first line of the text file to do so (will explain below, and please let me...

  • C++ please Programming Assignment #6 Help Me Find The Secret Message Description: This assignment will require...

    C++ please Programming Assignment #6 Help Me Find The Secret Message Description: This assignment will require that you read in an encrypted message from a file, decode the message, and then output the message to a file. The encryption method being used on the file is called a shift cipher (Info Here). I will provide you with a sample encrypted message, the offset, and the decrypted message for testing. For this project I will provide you main.cpp, ShiftCipher.h, and ShiftCipher.cpp....

  • 1 Objective Build a hashing algorithm that is suitable for use in a Bloom Filter. Please...

    1 Objective Build a hashing algorithm that is suitable for use in a Bloom Filter. Please note that while a cryptographic hash is quite common in many Bloom Filters, the hashing algorithm to be implemented is a mix of the the following algorithmic models, specifically, a multiply & rotate hash colloquially known as a murmur hash, and an AND, rolale, & XOR hash colloquially known as an ARX hash. 2 Requirements • Inputs. Read the input file which contains strings...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT