Caesar encryption (Julius Caesar) This method replaces each letter in a message with the letter that follows the fixed distance in the alphabet. (If it goes beyond the letter Z, it bypasses the starting position of the alphabet.) For example, if each letter is replaced with a letter from two positions in the alphabet, then Y is replaced with a,z and replaced by B. )
Then write the program .....
User input message and number of shifts to encrypt:
Do not change the letter ......
#include <stdio.h>#include<string.h>intMain () {Charpasswd[ -],encrypted[ -]; intI,j,k,t,move; while(1) {printf ("Enter message to be encrypted:"); Gets (passwd); printf ("Enter Shift Amount (1-25):"); scanf ("%d%*c",&move); for(i=0; I<strlen (passwd); i++) { if(Passwd[i] >='A'&& Passwd[i] <='Z') {Passwd[i]= ((passwd[i]-'A') +move)% -+'A'; } Else if(Passwd[i] >='a'&& Passwd[i] <='Z') {Passwd[i]= ((passwd[i]-'a') +move)% -+'a'; }} printf ("%s", passwd); printf ("\ n"); } return 0;}
And that's it.
such as input
Go head, make my day.
3
Output: Jr dkhdg, PDNH pb gdb.
......................................................
If this is the case, the input will decrypt:
Jr DKHDG, PDNH pb gdb.
23
Output: Go head, make my day.
Caesar password Encryption C language simple implementation