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...
Read three integers from user input.
Read three integers from user input.
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 * #...
Write a program that first gets a list of integers from input. The input begins with...
Write a program that first gets a list of integers from input. The input begins with an integer indicating the number of integers that follow. Assume that the list will always contain fewer than 20 integers. That list is followed by two more integers representing lower and upper bounds of a range. Your program should output all integers from the list that are within that range (inclusive of the bounds). For coding simplicity, follow each output integer by a space,...
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! ######################################## ##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...
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...
What are semi-weak keys for DES? Assume that the first permutation output of an original key...
What are semi-weak keys for DES? Assume that the first permutation output of an original key to DES is semi-weak. Describe a possible attack against DES encryption? Does this attack significantly reduce the security of DES? Please justify your answer.
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...
def vend():     a = {'key': '0', 'item': 'choc', 'price': 1.50, 'stock': (2)}     b = {'key': '1',...
def vend():     a = {'key': '0', 'item': 'choc', 'price': 1.50, 'stock': (2)}     b = {'key': '1', 'item': 'pop', 'price': 1.75, 'stock': 1}     c = {'key': '2', 'item': 'chips', 'price': 2.00, 'stock': 3}     d = {'key': '3', 'item': 'gum', 'price': 0.50, 'stock': 1}     e = {'key': '4', 'item': 'mints', 'price': 0.75, 'stock': 3}     items = [a, b, c, d, e]          def show(items):         cim = 0         for item in items:             if item.get('stock') == 0:                 items.remove(item)         for item in items:             print(item.get('key'), item.get('item'),item.get('price'),...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT