Lab 1
Lab 1
int i,j,cyphered_char_index;
//Looping through from 0 to size of plain text
for(i = 0; i < sizeof(plain_text); i++){
//Looping from 0 to size of alphabets list
for(j = 0; j < sizeof(alphabets); j++){
//Comparing plain text char of index i with alphabet of index j if true
if(plain_text[i] == alphabets[j]){
//If condition is true perform operation to encrypt the character
cyphered_char_index = ((j+key)%26);
//update cypher text at particular index to a cyphered char
cypher_text[index] = alphabets[cyphered_char_index];
//update index value to plus one
index++;
}
}
}
//Output the cyphered text here
printf("%s",cypher_text);
}
Results:
The application uses the Caesar Cipher and input cryptographic key to encrypt the plain text
and successfully encrypted.