alysha.recore 0 Newbie Poster

Hello everyone!

I have a homework assignment that I'm just not understanding...We're tyring to implement 4 total ciphers. I have the Caesar Cipher down:

#include <cstring>
#include "algorithms.h"

void caesarEncrypt( const char plaintext[] , char ciphertext[], int key )
{
    int idx;
    for( idx = 0; idx < strlen(plaintext); idx++ )
    {
        if ( CHAR_OUT_OF_RANGE(plaintext[idx]) )
        {
            ciphertext[idx] = plaintext[idx];
        }
        else
        {
            ciphertext[idx] = plaintext[idx] + key;
            if (ciphertext[idx] > 'z')
            {
                ciphertext[idx]-= NUM_CHARACTERS;
            }
            if (ciphertext[idx] < 'a')
            {
                ciphertext[idx] += NUM_CHARACTERS;
            }
        }
    }
    ciphertext[idx] = 0;    
}

void caesarDecrypt( const char plaintext[] , char ciphertext[], int key )
{
    int idx;
    for( idx = 0; idx < strlen(plaintext); idx++ )
    {
        if ( CHAR_OUT_OF_RANGE(plaintext[idx]) )
        {
            ciphertext[idx] = plaintext[idx];
        }
        else
        {
            ciphertext[idx] = plaintext[idx] - key;
            if (plaintext[idx] > 'z')
            {
                ciphertext[idx] -= NUM_CHARACTERS;
            }
            if (ciphertext[idx] < 'a')
            {
                ciphertext[idx] += NUM_CHARACTERS;
            }
        }
    }
    ciphertext[idx] = 0;
}

Now I also have to come up with a code for substitution, vigenere, and transposition. Can someone help me with figuring this out? I just need some help figuring out the logic for this program. Thank you in advance!