forked from jye-hollier/proj1
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtaskTwo.c
More file actions
25 lines (19 loc) · 679 Bytes
/
taskTwo.c
File metadata and controls
25 lines (19 loc) · 679 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
void taskTwo(void) {
char originalText[1000];
int key;
printf("\nPlease enter text to be encrypted:\n");
scanf (" %[^\n]%*c", originalText);
printf("\nPlease enter the rotation key number used:\n#");
scanf("%d", &key);
int stringLength = strlen(originalText);
char decryptedText[stringLength];
int i;
for(i = 0; i < stringLength + 1; i++) {
if (originalText[i] > 64 && originalText[i] < 91) {
decryptedText[i] = (((originalText[i] - 39) - key) %26 ) + 65;
}
else
decryptedText[i] = originalText[i];
}
printf("\nDecrypted text:\n%s", decryptedText);
}