diff --git a/ex03/main.c b/ex03/main.c index 9e51d6a..a1ae93f 100644 --- a/ex03/main.c +++ b/ex03/main.c @@ -14,10 +14,10 @@ int main(int argc, char *argv[]) { unsigned char buf[512] = {0}; size_t len = hex_to_bytes(buf, argv[1]); - unsigned char cur[512]; + char cur[512]; double min_score = INFINITY; - unsigned char key; - unsigned char best[512]; + char key; + char best[512]; // Test for keys from A to z for (char c = 65; c < 127; ++c) { for (size_t i = 0; i < len; ++i) { diff --git a/ex04/main.c b/ex04/main.c index e718d21..e10b596 100644 --- a/ex04/main.c +++ b/ex04/main.c @@ -31,7 +31,7 @@ int main(int argc, char *argv[]) { unsigned char buf[512] = {0}; len = hex_to_bytes(buf, line); - unsigned char cur[512] = {'\0'}; + char cur[512] = {'\0'}; for (char c = 32; c < 127; ++c) { for (size_t i = 0; i < len; ++i) { cur[i] = buf[i] ^ c; diff --git a/utils.c b/utils.c index 20e506e..d4aef38 100644 --- a/utils.c +++ b/utils.c @@ -50,7 +50,7 @@ char *bytes_to_base64(char *out, const unsigned char in[static 1], size_t len) { return out; } -double frequency_score(unsigned char *buf, size_t len) { +double frequency_score(const char *buf, size_t len) { static const double english_freqs[27] = { 0.08167, 0.01492, 0.02782, 0.04253, 0.12702, 0.02228, 0.02015, // A-G 0.06094, 0.06966, 0.00153, 0.00772, 0.04025, 0.02406, 0.06749, // H-N diff --git a/utils.h b/utils.h index 8bff75f..4cb4d2a 100644 --- a/utils.h +++ b/utils.h @@ -6,7 +6,7 @@ unsigned char hex_to_byte(const char c); size_t hex_to_bytes(unsigned char *out, const char hex[static 1]); char *bytes_to_base64(char *out, const unsigned char in[static 1], size_t len); -double frequency_score(unsigned char *buf, size_t len); +double frequency_score(const char *buf, size_t len); unsigned int hamming(const char *s1, const char *s2); #endif /* UTILS_H */