Question

In: Computer Science

Using block diagram, design the architectural layout of the simplified model of a symmetric Cryptosystem. Implement...

  1. Using block diagram, design the architectural layout of the simplified model of a symmetric Cryptosystem.
  2. Implement a cryptosystem columnar transposition technique with a 4 x 4 matrix arrangement. Test your code with ‘cryptography’ as the plaintext.

prefer python but it doesn't matter.

Solutions

Expert Solution

Q 1.

Q 2.

Python implementation of columnar transposition technique with a 4 x 4 matrix arrangement

# Python3 implementation of Columnar Transposition 
import math 

key = "HACK"

# Encryption 
def encryptMessage(msg): 
        cipher = "" 

        # track key indices 
        k_indx = 0

        msg_len = float(len(msg)) 
        msg_lst = list(msg) 
        key_lst = sorted(list(key)) 

        # calculate column of the matrix 
        col = len(key) 
        
        # calculate maximum row of the matrix 
        row = int(math.ceil(msg_len / col)) 

        # add the padding character '_' in empty 
        # the empty cell of the matix 
        fill_null = int((row * col) - msg_len) 
        msg_lst.extend('_' * fill_null) 

        # create Matrix and insert message and 
        # padding characters row-wise 
        matrix = [msg_lst[i: i + col] 
                        for i in range(0, len(msg_lst), col)] 

        # read matrix column-wise using key 
        for _ in range(col): 
                curr_idx = key.index(key_lst[k_indx]) 
                cipher += ''.join([row[curr_idx] 
                                                for row in matrix]) 
                k_indx += 1

        return cipher 

# Decryption 
def decryptMessage(cipher): 
        msg = "" 

        # track key indices 
        k_indx = 0

        # track msg indices 
        msg_indx = 0
        msg_len = float(len(cipher)) 
        msg_lst = list(cipher) 

        # calculate column of the matrix 
        col = len(key) 
        
        # calculate maximum row of the matrix 
        row = int(math.ceil(msg_len / col)) 

        # convert key into list and sort 
        # alphabetically so we can access 
        # each character by its alphabetical position. 
        key_lst = sorted(list(key)) 

        # create an empty matrix to 
        # store deciphered message 
        dec_cipher = [] 
        for _ in range(row): 
                dec_cipher += [[None] * col] 

        # Arrange the matrix column wise according 
        # to permutation order by adding into new matrix 
        for _ in range(col): 
                curr_idx = key.index(key_lst[k_indx]) 

                for j in range(row): 
                        dec_cipher[j][curr_idx] = msg_lst[msg_indx] 
                        msg_indx += 1
                k_indx += 1

        # convert decrypted msg matrix into a string 
        try: 
                msg = ''.join(sum(dec_cipher, [])) 
        except TypeError: 
                raise TypeError("This program cannot", 
                                                "handle repeating words.") 

        null_count = msg.count('_') 

        if null_count > 0: 
                return msg[: -null_count] 

        return msg 

# Driver Code 

# Plaintext 
msg = "cryptography"

cipher = encryptMessage(msg) 
print("Encrypted Message: {}". 
                        format(cipher)) 

print("Decryped Message: {}". 
        format(decryptMessage(cipher))) 

Output:

Hope this answers your questions, please leave a upvote if you find this helpful.


Related Solutions

asap please python Using block diagram, design the architectural layout of the simplified model of a...
asap please python Using block diagram, design the architectural layout of the simplified model of a symmetric Cryptosystem. Implement a cryptosystem columnar transposition technique with a 4 x 4 matrix arrangement. Test your code with ‘cryptography’ as the plaintext.
Choosing the best architectural style draw an architectural diagram for the following scenarios using MS Visio:...
Choosing the best architectural style draw an architectural diagram for the following scenarios using MS Visio: A vending machine used by passengers at a railway station. A-Zoom application conferencing system that allows video, audio, and computer data to be visible to several participants at the same time.
Using the simplified one-period model explain in words and illustrate via a diagram how moving from...
Using the simplified one-period model explain in words and illustrate via a diagram how moving from a proportional tax to a lump sum tax would increase consumer welfare. Explain why the lump sum tax is more efficient.
Instruction to assigned to each processor. ARM Cortex-A12 Draw neatly architectural or block diagram of the...
Instruction to assigned to each processor. ARM Cortex-A12 Draw neatly architectural or block diagram of the selected processor. Identify the following listed below features and explain briefly. Pipelining and stages Memory or Cache Fetch Unit and Decode units Instruction issue policy Register Renaming Reorder Buffer Reservation Station Branch Prediction Execution Units Processor speed Number of Cores Number of Threads 36 Levels of cache and separate or shared cache or instruction and data cache Hyper-Threading or TLP
Implementing a cryptosystem: Choose one of the following cryptography techniques and implement it using any programming...
Implementing a cryptosystem: Choose one of the following cryptography techniques and implement it using any programming language you prefer. Your program should provide the user with two options Encryption and Decryption, with a simple UI to get the input from the user, and view the result. You can use any restriction you need for the user input but you need to clarify that and validate the user input base on your restriction. ● Feistel ● Keyword columnar ● Any cryptosystem...
Design an ER Diagram for the given problem. Link the tables that are related and implement...
Design an ER Diagram for the given problem. Link the tables that are related and implement your design using MySQL. Insert at least a minimum of 5 records. Ensure that the data to be added are related to other tables. Post here the screenshot of the following: Entity Relationship Diagram with attributes, PK, and FK. Use the "describe" command to view the structure of the tables. Use the "select" command to view the contents of the tables. Company ABC has...
According to the perspective of QPSK digital signal processing, design a block diagram for the given...
According to the perspective of QPSK digital signal processing, design a block diagram for the given diagram below and explain for the given diagram (how does the signal go through the given diagram). The following figure is a  homodyne detection for coherent optical fiber communications . Once is the signal from laser and the other one is the local oscillator. After the QPSK demodulation, the electric field E will go through the photo diode detection. (you dont have to consider the...
Given the following specification, design a class diagram using PlantUML. To design the class diagram, use...
Given the following specification, design a class diagram using PlantUML. To design the class diagram, use abstract, static, package, namespace, association, and generalization on PlantUML Specification: A school has a principal, many students, and many teachers. Each of these persons has a name, birth date, and may borrow and return books. The book class must contain a title, abstract, and when it is available. Teachers and the principal are both paid a salary. A school has many playgrounds and rooms....
Design bcd adder diagram using 7486
Design bcd adder diagram using 7486
Draw a state diagram of the string pattern recognizer, implement it according to the design sequence...
Draw a state diagram of the string pattern recognizer, implement it according to the design sequence of the FSM, and draw a schematic diagram.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT