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.
Hi,
Are we allowed to call caesar-encrypt with a sign change for the key (ie negative to positive or positive to negative) within the caesar-decrypt function? This is my interpretation of "Calling it with some key n is exactly equivalent to calling caesar_encrypt with the key −n." Would this be marked down compared to writing very similar logic as caesar-encrypt in caesar-decrypt?
Well, really it's up to you to apply your best understanding of appropriate software development principles, and decide this for yourself. But perhaps expand on your thinking here, a little bit - can you suggest reasons for or against calling caesar-encrypt, vs reimplementing the logic?
cheers,
Arran
Hi,
Are we allowed to call caesar-encrypt with a sign change for the key (ie negative to positive or positive to negative) within the caesar-decrypt function? This is my interpretation of "Calling it with some key n is exactly equivalent to calling caesar_encrypt with the key −n." Would this be marked down compared to writing very similar logic as caesar-encrypt in caesar-decrypt?
Reimplementing the logic seems unecessary and redundant, as suitable code already exists in another function. It potentially also improves the readability of the function. On the other hand, it prevents any potential separation of caesar_decrypt from caesar_encrypt. For caesar_decrypt to work, it must always be able to access the caesar_encrypt function, which, if we are writing our program for future use by others, could be an issue. I am still uncertain of whcih implementation to go with, do you have any pointers? Thank you
But in brief: what we're writing in the project isn't really a program, but a library (admittedly a very small one) - a set of functions serving some common purpose. So as library maintainers, we can just declare: caesar_decrypt will never exist without caesar_encrypt also existing, because what would be the point of a decryption function without an encryption function?
So we are entitled to ignore that possibility, and write code that's simple and readable.
Cheers
Arran
ANONYMOUS wrote:
Reimplementing the logic seems unecessary and redundant, as suitable code already exists in another function. It potentially also improves the readability of the function. On the other hand, it prevents any potential separation of caesar_decrypt from caesar_encrypt. For caesar_decrypt to work, it must always be able to access the caesar_encrypt function, which, if we are writing our program for future use by others, could be an issue. I am still uncertain of whcih implementation to go with, do you have any pointers? Thank you