Python 3 - Computing a hash/checkdigit/etc. to verify which program was used

85 views Asked by At

I have a class of Computer Science students and am writing them a simple Python program to practice denary <-> binary conversions, they will have to hand in the text file output of the program eventually to confirm they can do them in a reasonable time. No problems there.

I also want to use that same program to demonstrate some Python to them, though, so they will need access to the source code.

My concern is that that makes it easy for them to cheat on the test by altering the source code to ensure that the output gives them full marks. What I would like to do is include a hash/checkdigit/some other form of verification that can also be output to the text file and will confirm that they used the program as I gave it to them, not a modified version.

Any algorithm based on their name, the date, etc. wouldn't be sufficient as they could just copy that algorithm over to their own version, it will need to be something unique to my supplied code. Perhaps based on the date of creation of my program? Or something else impossible to replicate.

Further, due to the limitations of the network this is to be run on, I only have access to those modules that come installed with IDLE.

Does anyone have any ideas for a suitable way of doing this?

1

There are 1 answers

0
Nanook On

I would write another script that imports the python program you described above. Within that script I would also use the email module to attach and send back your script, their script and the converted output file. Information on the email module can be found here --> https://docs.python.org/3.3/library/email-examples.html

Once you have all of there responses you can use a shell diff command to see if anyone modified your original code.