forked from jye-hollier/proj1
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtaskOne.c
More file actions
28 lines (19 loc) · 696 Bytes
/
taskOne.c
File metadata and controls
28 lines (19 loc) · 696 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
27
28
void taskOne(void) {
char originalText[1000];
int key;
printf("\nPlease enter text to be encrypted:\n");
scanf (" %[^\n]%*c", originalText);
printf("\nPlease enter rotation key number to be used:\n#");
scanf("%d", &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] = (((originalText[i] - 65) + key) %26 ) + 65;
}
else
encryptedText[i] = originalText[i];
}
printf("\nEncrypted text:\n%s", encryptedText);
}