Wednesday, 9 January 2019

Python program to implement Transposition cipher (CSS)

key = list(input("Enter your key: "))
matrix = {}
for i in key:
    matrix[i] = []

message = list(input("Enter your message: "))
temp = 0
for i in message:
    matrix[key[temp]].append(i)
    temp += 1
    if temp >= len(key):
        temp = 0

output = []
temp = len(sorted(matrix.items()))
print("The Encrypted text is: ", end="")
for i, v in sorted(matrix.items()):
    print("".join(v), end="")
print(" ")

No comments:

Post a Comment