diff --git a/src/caesarcrypt.c b/src/caesarcrypt.c index 1fb2713..5895192 100644 --- a/src/caesarcrypt.c +++ b/src/caesarcrypt.c @@ -29,10 +29,7 @@ int main() fgets(buf, 3, stdin); int choice = strtol(buf, NULL, 10); - //char* msg = calloc(128, sizeof(char)); - fputs("Enter your message text: ", stdout); - //if (msg) fgets(msg, 128, stdin); char* msg = dyninput_str(INT64_MAX); fputs("Enter your key (shift value): ", stdout); diff --git a/src/crypt.c b/src/crypt.c index 9d269c7..8a0c568 100644 --- a/src/crypt.c +++ b/src/crypt.c @@ -12,6 +12,12 @@ #include +/* + * For built in C mod operator (%) -1 % 26 == -1 + * For the requirements of this algorithm -1 mod 26 == 25 is required + * The below functions accomplish this +*/ + // Which of the two below functions is faster (find out!) inline int mod(int a, int b) { @@ -26,6 +32,11 @@ inline int fast_mod(int a, int b) } +/* + * 65 - 90 = ASCII 'A' - 'Z' + * 97 - 122 = ASCII 'a' - 'z' +*/ + inline bool isupper(char c) { return c >= 'A' && c <= 'Z';