BEST代写-线上编程学术专家

Best代写-最专业靠谱代写IT | CS | 留学生作业 | 编程代写Java | Python |C/C++ | PHP | Matlab | Assignment Project Homework代写

C语言代写|Project 2: Enigma Machine

C语言代写|Project 2: Enigma Machine

这是一个C语言代写的Project,主要与加密解密相关

Corrections and Additions

The original enigma_driver.c posted had a copy-and paste error which is now fixed. Please re
download enigma_driver.c, or see the piazza post here
(http://%20https://piazza.com/class/kyteryga3gu1go?cid=392) for how to fix the error.

Clarification: The message may contain spaces. Spaces are not encrypted. See the comment above
the signature for Encrypt().

Moved ROTOR_CONSTANTS to enigma_functions.c

Learning Goals

1. Learn how to write a C program that follows the given specifications.

2. Learn how functions improve code by making it modular and task-oriented.

3. Practice calling functions from different functions.

4. Practice passing arguments to functions.

5. Practice returning values from functions.

6. Develop code using one-dimensional and two-dimensional arrays.

7. Learn to write code that follows the commenting and the style guidelines.

Encryption and Decryption Using the Enigma Machine

Enigma machine uses rotors to encrypt messages. Inside the code for enigma_driver.c there is an array
of strings called ROTOR_CONSTANTS that stores nine rotors. For our project, the rotor at position 0 is
an identity rotor. It is a string with original English alphabets in the correct order.

Rotors at positions 1 – 8 of the array ROTORS are strings with the letters of the alphabet appearing in a
shuffled order. For example, the rotors 0 to 3 are shown below.

Rotor 0 – ABCDEFGHIJKLMNOPQRSTUVWXYZ
Rotor 1 – EKMFLGDQVZNTOWYHXUSPAIBRCJ
Rotor 2 – AJDKSIRUXBLHWTMCQGZNPYFVOE
Rotor 3 – BDFHJLCPRTXVZNYEIWGAKMUSQO

How to use rotors to encrypt messages?

Choose which rotors to use and in what order they will be applied. Rotate the letters in each rotor. For
each letter of the message, find the position in the identity rotor and look up the letter at the same
position in the encryption rotors. Then repeat with all of the other rotors.

Encryption using two rotors without rotations

Message: JAVA
Rotors to use: 31
Number of rotations: 0

Encrypted message:

Rotor 0 – ABCDEFGHIJKLMNOPQRSTUVWXYZ
Rotor 3 – BDFHJLCPRTXVZNYEIWGAKMUSQO

The J is at position 9 in the identity rotor (rotor 0) so we find position 9 in rotor 3 and look up the letter T.

Then we apply rotor 1.

Rotor 0 – ABCDEFGHIJKLMNOPQRSTUVWXYZ

Rotor 1 – EKMFLGDQVZNTOWYHXUSPAIBRCJ

Look up the letter T in the identity rotor. It’s at position 19. Find position 19 in rotor 1 and and look up the
letter. Repeat with the other letters.

Encrypted Message: PKOK

Decryption

To decrypt an encoded message we just apply the rotors in the reverse order. Look up the letter in the
encryption rotor, find its position then look up the letter at that position in the identity rotor. Then repeat
with the other rotors. In the above example, we find the letter P in rotor 1 at position 19 then look up the
letter at position 19 in the identity rotor, T. Then apply rotor 3. Find the letter T and look up the letter at
the same position in the identity rotor.

bestdaixie

评论已关闭。