forked from jye-hollier/proj1
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtaskThree.c
More file actions
26 lines (19 loc) · 720 Bytes
/
taskThree.c
File metadata and controls
26 lines (19 loc) · 720 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
26
void taskThree(void) {
char originalText[1000];
char key[26];
printf("\nPlease enter text to be encrypted:\n");
scanf (" %[^\n]%*c", originalText);
printf("\nPlease enter the encryption key in capitals:\n(E.g.: QWERTYUIOPASDFGHJKLZXCVBNM)\n\n");
scanf(" %[^\n]%*c", key);
int stringLength = strlen(originalText);
char encryptedText[stringLength];
int i;
for(i = 0; i < stringLength + 1; i++) {
if (originalText[i] > 64 && originalText[i] < 91) {
encryptedText[i] = key[(originalText[i]-65)];
}
else
encryptedText[i] = originalText[i];
}
printf("\nEncrypted text:\n%s", encryptedText);
}