BCN2023_LAB3

download BCN2023_LAB3

of 4

Transcript of BCN2023_LAB3

  • 8/3/2019 BCN2023_LAB3

    1/4

    COURSE: Data & Network Security MARKS:

    /10

    TOPIC: Cryptographic CODE: BCN2023

    ASSESSMENT: Lab

    Shee3NO: 3

    DURATION: 2

    hours

    #include ;

    #include ;

    main()

    {

    char input[80]; // Message to be encrypted

    // variable used

    int key =0;

    int i;int x;

    int j;

    char d;

    printf("************************************************************");

    printf("\n\t\t\t1.Encryption.");

    1

    1. What you should do :

    Problem :

    Using Previous Code from Labsheet 2 implement Decryption and Triple DES

    Substitution

    Cipher algorithm in C programming.

    Description :

    i. Add decryption function in your code

    ii. Add encryption function as triple DES

    iii. Use Switch & Case statements as your menu selection in your code

    iv. Eg. Case 1 for Encryption, Case 2 for Decryption and Case 3 for Triple DES

    Triple DES algorithm:

    If,C = CICSO, and p = 3 then

    E1= FLFVR

    E2= IOIYU

    E3= LRLBX

    INSTRUCTION:

    CODING:

  • 8/3/2019 BCN2023_LAB3

    2/4

    printf("\n\t\t\t2.Decryption.");

    printf("\n\t\t\t3.Encyption Triple DES.");

    printf("\n\t\t\t4.Exit");

    printf("\n************************************************************");

    printf("\n\n\t\tEnter Your Choice: ");

    scanf("%d",&d);

    printf("\n************************************************************");

    switch(d)

    { case 1:

    // Enter shift amount

    printf("\n\n\nEnter shift amount (1-25) : ");

    scanf("%d", &key);

    // enter message

    printf("Enter message to be encrypted: ");

    scanf("%s", &input);

    for(x=0; input[x] != '\0';x++)

    {

    // check if letter is captial or lower case

    if (input[x]>='A' && input[x]='a' && input[x]

  • 8/3/2019 BCN2023_LAB3

    3/4

    {

    if(input[i] >= 'A' && input[i]

  • 8/3/2019 BCN2023_LAB3

    4/4

    default:printf("\n\t\tWrong choice. Run the program again.");

    break;

    }

    }

    No Type of algorithm Output

    1 Encryption (Caesar Cipher)

    2 Decryption (Caesar Cipher)

    3 Triple DES

    4

    OUTPUT: