-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.c
More file actions
48 lines (39 loc) · 1.27 KB
/
test.c
File metadata and controls
48 lines (39 loc) · 1.27 KB
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "cipher.h"
int main(void) {
// create string to encrypt/decrypt
char hello[] = "Hello, world!";
char hello_en[] = "Lipps, asvph!";
// print the shift
short shift = 4;
print_shift(shift);
printf("Shift:\t\t%d\n", shift);
// example of encryption
printf("\nEncryption Example\n");
printf("Original:\t%s\n", hello);
char *encrypted = encrypt(hello, shift);
printf("Encrypted:\t%s\n", encrypted);
free(encrypted);
// example of decryption
printf("\nDecryption Example\n");
printf("Original:\t%s\n", hello_en);
char *decrypted = decrypt(hello_en, shift);
printf("Decrypted:\t%s\n", decrypted);
free(decrypted);
// edge case of encryption/decryption
printf("\nEmpty String Example\n");
char nothing[] = "";
printf("Original:\t%s\n", nothing);
char *nothing_decrypted = decrypt(nothing, shift);
printf("Decrypted:\t%s\n", nothing_decrypted);
free(nothing_decrypted);
// shift case of 26
printf("\nShift 26 Example\n");
printf("Original:\t%s\n", hello);
char *hello_encrypted = encrypt(hello, 26);
printf("Encrypted:\t%s\n", hello_encrypted);
free(hello_encrypted);
return EXIT_SUCCESS;
}