Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Assignment 6 Ciphers For this assignment we will be implementing 2 different cip

ID: 3819133 • Letter: A

Question

Assignment 6 Ciphers

For this assignment we will be implementing 2 different cipher algorithms, a caesar cipher and a Vigenere cipher. Caesar cipher takes a string and shifts all letters by a single key value. So if k=1 and the character in the string is ‘a’ it becomes ‘b’ etc and ‘z’ becomes ‘a’. Vigenere cipher uses a keyword to vary the amount that each letter gets shifted (‘a’ or ‘A’ is 0, ‘b’ or ‘B’ is 1, etc). For example, if the current letter in the keyword is ‘b’ and the plaintext letter is ‘p’ the cipher text character is ‘q’. The program is expected to run as follows: (Note: matching the text exactly is important and points will be taken off if your program doesn’t).

II. Error Checkin

A. Caesarcipher:possibleerrorsthatcanoccurisamissingcommandlineargument or a command line argument that isn't a number.

A. Errormessageshouldbe“Usage:caesar[key]”thenquit
B. VigenereCipher:possibleerrorscouldbethatthereisamissingkeywordora

keyword containing symbols or numbers.
A. Errormessageshouldbe“Usage:vignetter[keywordcontainingonlyletters]”

then quit

III. Grading

Functionality of Caesar: 30% (half will be awarded for code that compiles that is an attempt at a solution)
Functionallity of Vigenere: 40% (half will be awarded for code that compiles that is an attempt at a solution)

Style: 30%

IV. Submission

Submit a single zip file ciphers.zip containing caesar.c, vigenere.c and an optional README.txt (if there is anything that I should know when grading) to the MyCourses Dropbox by the deadline.

Due Date: 11/28 at 11:59pm

V. Remarks

- Must use pointers to keep your current place in the plaintext and keywords
- Only letters should be encrypted. Numbers and other non letters shouldn't be shifted. - Assume plaintext is 19 characters of text or less.
- Lecture code is your friend.

VI. References

https://en.wikipedia.org/wiki/Caesar_cipher

http://practicalcryptography.com/ciphers/caesar-cipher/

https://en.wikipedia.org/wiki/Vigenere_cipher http://practicalcryptography.com/ciphers/classical-era/vigenere-gronsfeld-and-autokey/

Explanation / Answer

Caesar Cipher

#include<stdio.h>
char* caesar(char string[])
{
    int i=0;
    while(string[i]!='')
    {
        if((string[i]>='a' && string[i]<='z')||(string[i]>='A' && string[i]<='Z'))
        {
            if(string[i]=='z')
                string[i]='a';

            else if (string[i]=='Z')
                string[i]='A';
            else
                string[i]++;

        }

        else
        {
            printf("use only letter");
            return "";
        }

        i++;
    }
     return string;
}

void main()
{
    char plainText[20];char* cipherText;
    printf(" enter plain text:");
    gets(plainText);
    cipherText = caesar(plainText);

    printf(" %s",cipherText);

}

Vigenere Cipher