Question

In: Computer Science

message = 'youcannotdecodemyciphertexttoday' def transposition_cipher_encode(plain_text, key): # the input, key should be a permutation of integers...

message = 'youcannotdecodemyciphertexttoday'

def transposition_cipher_encode(plain_text, key):
# the input, key should be a permutation of integers 0 to some number
# your code here
return

need code in PYTHON

Solutions

Expert Solution

def transposition_cipher_encode(plain_text,key):

data={int(v): n for n, v in enumerate(key)}

cipher_text = ''

for index in sorted(data.keys()):

for s in [plain_text[i:i + len(key)] for i in range(0, len(plain_text), len(key))]:

try:

cipher_text =cipher_text+s[data[index]]

except:

continue

return cipher_text

message = 'youcannotdecodemyciphertexttoday'

key="12564"

print(transposition_cipher_encode(message,key))


Related Solutions

In this program, the user will enter some permutation of the integers 0 to n-1, inclusive,...
In this program, the user will enter some permutation of the integers 0 to n-1, inclusive, (each integer in that range will appear exactly once) followed by -1 to indicate the end of the input. The user will never input more than 100 numbers. Your job is to store all the numbers in an array in the order they are input. For example if the user inputs 3 0 2 1 -1 then you should store the 3 at index...
In python can you fix the error in the line where it says message = input("Input...
In python can you fix the error in the line where it says message = input("Input a lowercase sentence: ") this is the error message I get after running the program and inputing a lowercase sentence Input a lowercase sentence:hello hi MM§MTraceback (most recent call last): MM§M File "client.py", line 14, in <module> MM§M message = input("Input a lowercase sentence:") MM§M File "<string>", line 1 MM§M hello hi MM§M ^ MM§MSyntaxError: unexpected EOF while parsing from socket import * #...
Read three integers from user input.
Read three integers from user input.
Try to debug it! ######################################## ##def rev_list_buggy(L): ## """ ## input: L, a list ## Modifies...
Try to debug it! ######################################## ##def rev_list_buggy(L): ## """ ## input: L, a list ## Modifies L such that its elements are in reverse order ## returns: nothing ## """ ## for i in range(len(L)): ## j = len(L) - i ## L[i] = temp ## L[i] = L[j] ## L[j] = L[i] # ## FIXES: -------------------------- ## temp unknown ## list index out of range -> sub 1 to j ## get same list back -> iterate only over...
What is the average performance of Quicksort assuming every input permutation is equally likely? Prove it....
What is the average performance of Quicksort assuming every input permutation is equally likely? Prove it. Hint: In this case pivot(split) element very likely to provide good balance during partition.
Try to debug it! (fixes needed are explained below) ######################################## ##def primes_list_buggy(n): ## """ ## input:...
Try to debug it! (fixes needed are explained below) ######################################## ##def primes_list_buggy(n): ## """ ## input: n an integer > 1 ## returns: list of all the primes up to and including n ## """ ## # initialize primes list ## if i == 2: ## primes.append(2) ## # go through each elem of primes list ## for i in range(len(primes)): ## # go through each of 2...n ## for j in range(len(n)): ## # check if not divisible by...
The program asks user to enter three integers, and the displays a message indicating whether the...
The program asks user to enter three integers, and the displays a message indicating whether the numbers are in sequential order, in reverse order or in neither order. Find the errors and correct the program codes in the if comparison expressions. (10 points) 1.     using System; 2.     using static System.Console; 3. 4.     class Sorting 5.     { 6.              static void Main() 7.              { 8.                       int num1, num2, num3; 9.                       string snum1, snum2, snum3; 10.                    Write ("Enter first number "); 11.                    snum1...
Write a C++ program to do the following USING ARRAYS 1) input 15 integers (input validation...
Write a C++ program to do the following USING ARRAYS 1) input 15 integers (input validation , all numbers must be between 0 and 100) 2) find the largest number 3) Find the Smallest Number 4) Find the Sum of all numbers in the Array Display: as per the user's section (menu using switch or if else ) Largest Number Smallest Number Sum of all numbers the original Array DO NOT USE METHODS OR FUNCTIONS Submit: Source code (C++) output...
(CODE IN PYTHON) Program Input: Your program will display a welcome message to the user and...
(CODE IN PYTHON) Program Input: Your program will display a welcome message to the user and a menu of options for the user to choose from. Welcome to the Email Analyzer program. Please choose from the following options: Upload text data Find by Receiver Download statistics Exit the program Program Options Option 1: Upload Text Data If the user chooses this option, the program will Prompt the user for the file that contains the data. Read in the records in...
Write a complete MiniMIPS program that accepts a seqeunce of integers at input and after the...
Write a complete MiniMIPS program that accepts a seqeunce of integers at input and after the receipt of each new input value, displays the largest and smallest integers thus far. An input of 0 indicates the end of input values and is not an input value itself. Note that you do not need to keep all integers in memory.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT