// Arup Guha
// 8/24/2026
// Code for shift cipher

#include <stdio.h>
#include <string.h>

int main() {

    // Set up a plaintext.
    char letters[27] = "abcdefghijklmnopqrstuvwxyz";
    char cipher[27];
    int key = 12;
    int len = strlen(letters);

    // Here is how to encrypt
    for (int i=0; i<len; i++) {

        // Ascii --> Number(0-25) --> Encrypt Number --> Letter
        cipher[i] = ( (letters[i]-'a') + key )%26 + 'a';
        printf("%c", cipher[i]);
    }
    cipher[26] = '\0';
    printf("\n\n");

    // Decrypt
    for (int i=0; i<len; i++) {

        // Letter --> Number --> Decrypt Number --> Add 26 --> Mod --> To Letter
        char c = ( (cipher[i] - 'a') - key + 26)%26 + 'a';
        printf("%c", c);
    }
    printf("\n");
    return 0;
}
