It's UWAweek 47

help3007

This forum is provided to promote discussion amongst students enrolled in CITS3007 Secure Coding. If posting a question, it's suggested you check first whether your question is answered in the unit Frequently Asked Questions (FAQ) list, and use the search box (on the right) to see if an answer to your question has already been posted.

Please consider offering answers and suggestions to help other students! And if you fix a problem by following a suggestion here, it would be great if other interested students could see a short "Great, fixed it!"  followup message.

Note that any posts must comply with the UWA Code of Conduct and the UWA Academic Conduct Policy. That means you should (a) treat everyone with respect and courtesy, and (b) not post your solutions to an assessment that's in progress.

If asking a programming question, it's recommended you read How do I ask a good question? If reporting or troubleshooting a bug in software used in the unit, it's recommend you read How to report bugs effectively.
Displaying the 7 articles in this topic
Showing 7 of 170 articles.
Currently 27 other people reading this forum.


 UWA week 18 (1st semester, week 9) ↓
SVG not supported

Login to reply

👍?
helpful
7:30pm Fri 3rd May, Hugo S.

Hi Arran, I found this function declaration in crypto.h
void vigenere_decrypt(char range_low, char range_high, int key, const char * cipher_text, char * plain_text);
can I assume that the key is supposed to be passed as a string instead of an int?
void vigenere_decrypt(char range_low, char range_high, const char * key, const char * cipher_text, char * plain_text);


SVG not supported

Login to reply

👍?
helpful
1:43pm Sun 5th May, Taylah K.

Hey I think I've found another typo. In the pdf the caesar decrypt declaration has plain_text before cipher_text: void caesar_encrypt(char range_low, char range_high, int key, const char * plain_text, char * cipher_text); But crypto.h has them the other way around: void caesar_decrypt(char range_low, char range_high, int key, const char * cipher_text, char * plain_text);


SVG not supported

Login to reply

👍?
helpful
1:44pm Sun 5th May, ANONYMOUS

Hey I think I've found another typo. In the pdf the caesar decrypt declaration has plain_text before cipher_text: void caesar_decrypt(char range_low, char range_high, int key, const char * plain_text, char * cipher_text); But crypto.h has them the other way around: void caesar_decrypt(char range_low, char range_high, int key, const char * cipher_text, char * plain_text);


 UWA week 19 (1st semester, week 10) ↓
SVG not supported

Login to reply

👍?
helpful
12:44pm Mon 6th May, Arran S.

Hi Hugo,

You're correct, and I've updated the header file.

Cheers

Arran

"Hugo Smith" [email protected] wrote:

Hi Arran,

I found this function declaration in crypto.h

void vigenere_decrypt(char range_low, char range_high, int key, const char * cipher_text, char * plain_text);

can I assume that the key is supposed to be passed as a string instead of an int?

void vigenere_decrypt(char range_low, char range_high, const char * key, const char * cipher_text, char * plain_text);


SVG not supported

Login to reply

👍?
helpful
12:48pm Mon 6th May, Arran S.

Hi Taylah,

No, that's not a typo. Typically in related functions, we put input and output parameters in a consistent order. In the encryption function, cipher_text is an output. But in the decryption function, plain_text is the input, and cipher_text is the output. You can tell, because an input parameter is normally marked const, to indicate that it shouldn't be changed, whereas the output parameter is not (it's just a plain char *).

In some of the C library function, output parameters come first – e.g. memcpy, which has the prototype void *memcpy(void *dest, const void *src, size_t n). I'm not sure what the reasoning is, but in my code (and a lot of other C code I've seen), the output parameters tend to go at the end.

I hope that clarifies things! Let me know if you have any other questions.

cheers,

Arran

"Taylah Karran" [email protected] wrote:

Hey I think I've found another typo. In the pdf the caesar decrypt declaration has plain_text before cipher_text: void caesar_encrypt(char range_low, char range_high, int key, const char * plain_text, char * cipher_text); But crypto.h has them the other way around: void caesar_decrypt(char range_low, char range_high, int key, const char * cipher_text, char * plain_text);


SVG not supported

Login to reply

👍?
helpful
9:21am Tue 7th May, Taylah K.

Hi Arran,

Apologies, I copied the wrong function in my initial question, In the pdf the caesar decrypt declaration has plain_text before cipher_text:

void caesar_decrypt(char range_low, char range_high, int key, const char * plain_text, char * cipher_text);

But crypto.h has them the other way around:

void caesar_decrypt(char range_low, char range_high, int key, const char * cipher_text, char * plain_text);

So it throws an error when I go to compile.


SVG not supported

Login to reply

👍?
helpful
10:33am Tue 7th May, Arran S.

Gotcha - the crypto.h version is the correct one (for the reasons I gave - the output parameter comes last).

So that's how you need to code your implementation - does that help?

Cheers

Arran

"Taylah Karran" [email protected] wrote:

Hi Arran,

Apologies, I copied the wrong function in my initial question, In the pdf the caesar decrypt declaration has plain_text before cipher_text:

void caesar_decrypt(char range_low, char range_high, int key, const char * plain_text, char * cipher_text);

But crypto.h has them the other way around:

void caesar_decrypt(char range_low, char range_high, int key, const char * cipher_text, char * plain_text);

So it throws an error when I go to compile.

The University of Western Australia

Computer Science and Software Engineering

CRICOS Code: 00126G
Written by [email protected]
Powered by history
Feedback always welcome - it makes our software better!
Last modified  8:08AM Aug 25 2024
Privacy policy