-
Notifications
You must be signed in to change notification settings - Fork 48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Finished implementation of encode and decode #94
base: main
Are you sure you want to change the base?
Conversation
i can code review this |
I can code review this! |
High Level Checks:
Code Checks:
Great job! This is a really nice project. It resolves the task, to encode and decode, it has tests, follows code formatting standards, compiles and runs and documentation is included. I will say the directions were a little confusing. I would suggest making it a little more explicit so the user doesn't need to do any trouble shooting and can just copy and paste commands. For example, step 1, run "make qemu" step 2: if binary run encode project1.txt -b, step 3: the file will now be saved to a new name encrypted.txt, to decode run _____ etc... However, the documentation is still good enough to get it up and running so that's just a small thing. As I was running it, I tried to run it with -b and then decode with -a, which left me with a decoded text of a question mark. I would say that this edge case could've been handled a little better, which is the only thing that I said you missed but that might be outside of the scope so I didn't mark you down. However you do handle opening a file error! Which is an important edge case. The code is definitely organized, has great documentation and maintains the same level of performance. Great job again! |
@@ -0,0 +1,137 @@ | |||
/********************************************************************* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great documentation!
// Since 3 input bytes = 4 output bytes, determine out how many even sets of | ||
// 3 bytes the input has. | ||
blk_ceiling = blks * 3; | ||
for (idx = 0, idx2 = 0; idx < blk_ceiling; idx += 3, idx2 += 4) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Really interesting logic!
return(idx2); | ||
} | ||
|
||
size_t base64_decode(const BYTE in[], BYTE out[], size_t len) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Appreciate how many functions you have. Very maintainable and readable code!
int | ||
main(int argc, char *argv[]) | ||
{ | ||
char *crypto_option = argv[1]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here if where you could probably add something for the edge case I brought up in the final comment, or maybe in the decode logic you could have some kind of flag in the file that you check so they always decode in the same format
char *crypto_option = argv[1]; | ||
char *file_name = argv[2]; | ||
|
||
int fd = open(file_name, O_RDONLY); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice edge case checking!
|
||
int fd = open(file_name, O_RDONLY); | ||
if (fd < 0) { | ||
printf("ERROR, could not open the file %s\n", file_name); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
More error checking! Nice!
@@ -0,0 +1 @@ | |||
hi this is a secret |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for adding in these test files! Made it super easy to make sure your code works.
This is a really nice job and perfect for P1's scope. The formatting and organization is well done. I have encountered a few minor issues:
Beyond that, I think it would be great to be able to tweak the input file and output file handling a bit. By default, most unix programs read from stdin, so you could do that if no input file is specified. Additionally, most programs just write to stdout, so if you write control messages to stderr then you could avoid the code for writing files and instead just print to stdout. If a user wants an output file, they can just do Overall this is a great effort. If you fix the very minor bugs above you can earn +0.5 back on your project score. |
Overview:
Modifications:
How to run:
/encode -s or -b or -a project1.txt
/decode -b encrypted.txt