Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upCryptography using C #585
Cryptography using C #585
Conversation
All files are checked and tested on various platforms. |
Thank you for the contributions
This was mentioned in the PR description as one of the checklist for the authors. Please ensure the description is completed the checklist is followed. Thank you |
Done changes |
This comment was marked as outdated.
This comment was marked as outdated.
Thank you. /**
* @file
* @brief Add one line description here
* @details
* This is a multi line
* description containing links, references,
* math equations, etc
* @author [Name](https://github.com/handle)
* @see related_file.c, another_file.c <-- this line is optional
*/
#include
/**
* Structure documentation
*/
struct strct_name {
int var1; /**< short info of this variable */
char *msg; /**< short info */
};
/**
* Function documentation
* @param param1 one-line info about param1
* @param param2 one-line info about param2
* @returns `true` if ...
* @returns `false` if ...
*/
bool func(*int param1, size_t param2) {
// function statements here
if(/*something bad*/)
return false;
return true;
}
/** Test function
* @returns None
*/
void test() {
/* some statements */
assert(func(...) == ...); // this ensures that the algorithm works as expected
// can have multiple checks
}
/** Main function
* @returns 0 on clean exit
* @returns nonzero on error.
*/
int main(int argc, char *argv[]) {
// code here
return 0;
} |
Added documentation to the code |
No need of test cases in code therefore not implemented test cases |
Thank you, @Rishabhpatel803
|
Ok i will update it by tomorrow |
done adding test cases to the program |
Well written code. Please review the suggestions and comments. The code, lacks in the documentation standards. Please refer to the Doxygen standards and also my comment from above where I provided with a full snippet of documenting functions, function parameters, etc. Thank you |
} | ||
} | ||
printf("\nEncrypted message: %s", msg); | ||
decrypt(msg, key); |
This comment has been minimized.
This comment has been minimized.
kvedala
Aug 7, 2020
Collaborator
should not happen here.
Encrypt should only perform encryption
Also, it would be better to make the encrypt and decrypt functions atomic. The printf statements should be made by the calling function.
{ | ||
char msg[] = "Grofers"; | ||
printf("First Texst case"); | ||
encrypt(msg, 5); |
This comment has been minimized.
This comment has been minimized.
kvedala
Aug 7, 2020
Collaborator
This does not test
the implementation. To test,
char *original_msg = "Gofers";
char msg[10];
strcpy(msg, original_msg); // retain original copy
int key = 5;
encrypt(msg, key); // encrypt the text.
decrypt(msg, key); // decrypt the text with the same key
assert(strcmp(msg, original_msg) == 0); // this will ensure that after encrypt and decrypt operations, the original message was obtained. This will fail if there is an error in the code.
#include <string.h> | ||
#define MX 5 | ||
|
||
int choice; |
This comment has been minimized.
This comment has been minimized.
kvedala
Aug 7, 2020
Collaborator
Use of global variables is discouraged. Please pass variables as function arguments.
* designing the function of encryption and | ||
* decryption using playfair cipher | ||
*/ | ||
void playfair(char ch1, char ch2, char key[MX][MX]) { |
This comment has been minimized.
This comment has been minimized.
kvedala
Aug 7, 2020
Collaborator
void playfair(char ch1, char ch2, char key[MX][MX]) { | |
void playfair(char ch1, char ch2, char **key) { |
Can the function be made better by allowing any size of keys and arrays? Not mandatory, but a suggestion.
#include <ctype.h> | ||
#include <stdio.h> | ||
#include <string.h> | ||
#define MX 5 |
This comment has been minimized.
This comment has been minimized.
kvedala
Aug 7, 2020
Collaborator
If using macros, please use descriptive names of at least 5 characters long. Something like KEY_SIZE
?
{ | ||
char msg[] = "Playfair", key[] = "Good"; | ||
choice = 1; | ||
printf("First Test Case"); |
This comment has been minimized.
This comment has been minimized.
kvedala
Aug 7, 2020
Collaborator
Please refer to the suggestion made for the teaser cipher code on implementing a self-test funcition.
Rishabhpatel803 commentedJul 30, 2020
•
edited by gitpod-io bot
Description of Change
References
Checklist
Notes: