We have a university programming course and fellow students are asking some programming questions in our Facebook group. I’m a little hesitant to share all of my programs, especially if it’s something cool for one of the assignments, since these are looked at by the TAs and they might notice if somebody has the same program and start asking questions on where it came from. Still, sometimes I’d like to share my code to help others, but I don’t wanting people just grabbing my work.(Clarification: We are allowed to collaborate with the tasks) This is of course a thin line. While I want to help some people, I’m concerned that they may not have the academic honesty to rewrite the code on their own.
Most of my fellow students are not very advanced in their skills, so I’d get away with say hiding my name in Base-64 encoded string crafted into a discrete place. Still, it may be too obvious for a random string to be sitting around.
What options exist to hide my name in a program without it looking suspicious?
I’ve seen over at CodeGolf that they have made ascii art turn into other things when evaluated. Are there similar strategies I could utilize? The ideal solution would be something that looks like something that fits in discreetly but in reality has a function to prove that I coded it from the beginning.
Clarification: (Sorry, should have said this earlier) We’re allowed to collaborate but have to explain our programs to the TAs to get the points. It’s just for satisfaction to hide some Easter Eggs in other’s code if it leaks out, especially since it may be tempting to exchange programs to check that the answers to problems they generate are equivalent etc or to see how others solve the problem.
11
Use your signature not in your code, but in a publicly accessible development log.
Publish your code at a public Github repo. Include a Docblock with your name in the “Author” field. This way there’s a public record of you being the actual author of the program.
This may not qualify as “hiding”, but in my opinion, it does. If a student decides to copy your code, they will think that they only have to swap their signature for yours. Imagine their surprise when you present public evidence of their wrongdoing. To make matters worse for them, it’s accessible online. You can even use an online tool, such as Diffchecker, to demonstrate which parts of your code were stolen!
EDIT: As pointed out in the comments, make sure your school allows to share your work this way! OP indicated that their institution is OK with this, but yours might not be!
15
“since these are looked at by the TAs and they might notice if somebody has the same program”
I’d hope so, it’s part their job to detect and punish cheating, plagiarism, and other fraud.
And duplicating the work of others and passing it off as your own is that, cheating and plagiarism.
So quite simple: don’t give out your work to others. Help them write their own if you want by giving them ideas on how to solve problems, then let them do their own coding.
3
Like the above answer I encourage using something like Github to log your development of the code, there are other methods that you could use to cover your back such as emailing the source to yourself prior to the sharing of it, though a publicly viewable repository is what I’d strongly suggest.
That is of course if the sharing of code is highly necessary. What about pseudo-code? or like “ratchet freak” stated, share the idea not the implementation. (this makes more sense for more complex code)
You could also use one of the oldest tricks in hiding messages. Make the first letter of each variable hide a message. For example,
$Image = "test";
$a = "/test/img.jpg";
$message = "This is img.jpg";
$Full = 435674;
$rate = 3;
$ascii = "---....!--";
$number = 2040;
$k = 5;
// Do some work here?
1
I think that GitHub or a similar solution is okay, BUT there are two things to consider:
- This is still giving your work to others who are supposed to do it by themselves, so it might be punishable no matter if you hide some sort of an Easter egg in it or not.
- The policy of the school might actually be pretty restrictive to such things. In Germany, for example, there are a number of universities, who even make their students sign a sort of a “contract”, which states that everything they develop as a part of an assignment given in this and that course is property of the university and cannot be distributed in any form without the explicit permission of the institution. So before posting school stuff on the Internet I strongly advice you to ask (there are usually people who work on these things in each and every educational and scientific institution), because you might actually get into trouble and with that I don’t mean just getting an F, but much worse. If you really want to help your mates, you can ask your professor if you can be a tutor or something similar and do it all out in the open.
2
Cartographers have the same problem. A couple techniques:
-
Introduce an improbable deviance from your language’s traditional style, e.g. always have imbalanced spaces around operators
if (lefthand== righthand)
-
Scatter no-ops throughout your code, if they’re part of the language you’re using.
lefthand = righthand;;
4
Preventing plagiarism in NOT your job as a student, that’s purely in the hands of an instructor / TA.
Generally speaking treat school like it were closed source business. Your fellow students are colleagues for other employers. You can not share code beyond simple one liners and such, and you NEVER share entire classes or projects.
Hiding “Easter Eggs” in code is generally viewed as unprofessional. (Opinions may vary here)
Don’t make smelly code your signature
Your “signature” or how you differentiate your code from others should be tasteful, and not hinder your code “smell” in any manner. This is why I strongly discourage the following:
- Intentionally misspelling things (variables, method names)
- Intentionally adding code “oddities” like no-ops for the purposes of marking code as yours.
- Using non-standard or unusual code structure (white space, line breaks, ect)
- Using non-standard or unusual coding patterns (actual code logic)
- Unnecessary obfuscation of code (burying methods with in methods without reason)
- Any other sort of code trickery or wizardry to try and distinguish it in an unusual manner.
Then how do I protect my code?!
Generally speaking restricting availability is your best way to protect your code. If you don’t make it public and no one hacks your computer your code is generally safe. Sure it could be decompiled, reverse engineered, etc. At that point it’s not like it’ll match the code that generated it anyways.
I want to make it public, but prevent it from being plagiarized
Just no… By all means messy wizardry in your code could make a plagiarist stand out assuming that they make their code available as well… and they won’t.
It’ll also make you look terrible when others look over your code and go. “what the hell is with all the typos and no-ops?”
But I want a code signature, something I can look at code and say I did this, it was me, this is mine
Honestly if you code well it should generally be indistinguishable from any other code in the projects you work on. Sure their might be nuances that let you know what you worked on versus what Bob did, but these should be fairly mild.
The only time code stands out in a big way among peers is if something is new and never been done before within your circle, or it smells in a way unique to your circle.
2
Given that the problem is to hide a signature in source code where
- it will not be immediately obvious
- it cannot be removed casually or accidentally
- it can be recovered found when needed, to a level of certainty that would constitute proof.
An interesting variation on Steganography.
You can’t use formatting or whitespace, because that can be trivially removed by any competent IDE.
That really leaves only naming of variables and functions. You can’t use a common distinctive substring, because it’s too easily removed by a search and replace. That leaves the use of distinctive and original variable names that would be have to be removed individually. Spelling errors and foreign language words are good candidates.
if (a== x) {} // disappears on reformatting
int gghhjj_i; // easily removed by search and replace, if all the same
int couunt = 0; //spelling
int nummer = 0; // german
float doppel = 0.0; // german
string spago = "xx"; // italian
boolean manana = true; // spanish
struct perzon; // excess use of z's.
class employeej; // what if every variable contained a 'j'?
The opportunities for creativity are boundless!
Then some simple text processing to extract and compare tokens will rapidly discover the plagiarists.
5
duozmo’s suggestion of noops will possibly generate poor marks for sloppiness, but that might be a good thing to include in example code which is not supposed to be used verbatim.
That inspired me to think of an alternating signature pattern of tabs and spaces in both leading and trailing whitespace.
1
Something similar I’ve used before is to create variables named the same as other important variables but leet their names depending on the text editor so the change is not easily obvious, or use letters with accents.
Call several functions, to which you send many of the program’s important variables from an if statement, utilising your variables, which will never be true, eg if( 1eft == wrōng)
Set some important variable in a useless function to your obfuscated signature.
You should be able to find several tutorials on ‘How to write unmaintainable code’ which could help.
3