You are on page 1of 5

BSIT-3A

FINAL PROJECT (CAESAR CIPHER)


Program:
//Our Final Project_INFORMATION ASSURANCE IN SECURITY 1 (C++)

//CAESAR CIPHER PROJECT

//Group members:
//Kathryn Ann G. Florentino
//Merilyn L. Paguigan
//Arnold Gatan
//Chammy Malenab

#include<iostream>
#include<string.h>

using namespace std;

void encryptyfunc()
   {
     char text[100];
     char group;
     int k, key;

  cout <<"*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*\n";
  cout <<"\nEnter a message of Plaintext: ";
  cin >>text;
  cout <<"*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*\n";
  cout <<"\nEnter Secret key: ";
  cin >> key;

  for(k = 0; text[k] != '\0'; ++k){


    group = text[k];

    //Kung ang mensaheng i-encode a nasa lower case


    if(group >= 'a' && group <= 'z'){
      group = group + key;

      if(group > 'z'){


        group = group - 'z' + 'a' - 1;
      }

      text[k] = group;
    }

    //Kung ang mensaheng i-encode ay nasa upper case


    else if(group >= 'A' && group <= 'Z'){
      group = group + key;

      if(group > 'Z'){


        group = group - 'Z' + 'A' - 1;
      }

      text[k] = group;
BSIT-3A

    }
  }

  cout <<"*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*\n";
  cout << "\nThe Encrypt message: " << text <<endl;
  cout <<"*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*\n";
}

void decryptfunc()
{
    char text[100];
    char group;
    int k, key;

    cout <<"*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*\n";
    cout <<"\nEnter a message of Ciphertext:  ";
    cin >>text;
    cout <<"*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*\n";
    cout <<"\nEnter Secret key: ";
    cin >> key;

  for(k = 0; text[k] != '\0'; ++k){


    group = text[k];

    //Kung ang mensaheng i-encode ay nasa lower case.


    if(group >= 'a' && group <= 'z'){
      group = group - key;

      if(group < 'a'){


        group = group + 'z' - 'a' + 1;
      }

      text[k] = group;
    }

    //Kung ang mensaheng i-encode ay nasa upper case.


    else if(group >= 'A' && group <= 'Z'){
      group = group - key;

      if(group < 'A'){


        group = group + 'Z' - 'A' + 1;
      }

      text[k] = group;
    }
  }
  cout <<"*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*\n";
  cout << "\nThe Decrypt message: " <<text <<endl ;
  cout <<"*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*\n";
}

int main()
{
  jump:
BSIT-3A

  int choice;

  cout<<endl;
   cout <<"               *~>Caesar Cipher<~*\n";
  cout <<"*-------------------------------------------*\n";
  cout << "|          Press ~> 1 Encryption            |";
  cout << "\n|          Press ~> 2 Decryption            |"<<endl;
  cout <<"*-------------------------------------------*\n";
  cout << endl;
  cout << "Choose one of Caesar Cipher: ";
  cin >> choice;

  switch(choice)
  {
    case 1: encryptyfunc();
            break;
    case 2: decryptfunc();
            break;
    default:
  cout <<"\n*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*\n";
  cout << "         You entered are Invalid!";
  cout <<"\n*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*\n";
            break;
  }

  char c;
    cout << "\nDo you want run more [y/n]: ";
    cin >> c;
      if (c == 'n')
      {
        cout <<"Thank You!";
        return 0;
      }
        else if (c == 'y')
        {
          goto jump;
        }
  }
BSIT-3A

Output:
Entered number 1 and 2

If entered unmentioned
BSIT-3A

GROUP MEMBERS:
Kathryn Ann Florentino
Merilyn Paguigan
Arnold Gatan
Chammy Malenab

You might also like