Cryptography & Network Security LAB

Program in C to XOR each character in the given string with 0.

Input







Only alphabetical string is acceptable.
String length can range from 1 to 10.


Decrypt







Process


118ASCII value of Character

Output

Encryption

Decryption

Code Execution

#include<stdio.h>
#include<string.h>
char output_str[20];
char *enc_dec(char *text,char key);
void main(){
        char input_str[20],*enc_str,*dec_str,enc_key;
        printf("\nEnter String\n");
        gets(input_str);
        printf("\nEnter Encryption Key\n");
        scanf("%c",&enc_key);
        getchar();
        enc_str=enc_dec(input_str,enc_key);
        printf("\n%s\n",enc_str);
        printf("\nEnter String\n");
        gets(input_str);
        printf("\nEnter Decryption Key\n");
        scanf("%c",&enc_key);
        dec_str=enc_dec(input_str,enc_key);
        printf("\n%s\n",dec_str);
}
char *enc_dec(char *text,char key){
        int i;
        for (i = 0; i < strlen(text); i++)
                output_str[i]=text[i]^key;
        return (char *)output_str;
}


Attempt Task

  1. What will be the output if we xor any character with integer number 0?





  2. Decryption process and Encryption process in XOR-Cipher is different.



  3. XOR returns 1 if:





  4. In C progamming language exor is represented by:






  5. Mark the most suitable option. In this experiment XOR-Cipher is performed on: