31

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.

MikeFoxtrot
  • 591
  • 4
  • 12
  • 70
    don't share code but share ideas – ratchet freak May 05 '14 at 09:42
  • 7
    What I had done few years ago was having a variable with a specific name (In my case: "pkmn") which I used in every code I wrote, for things not noticeable (the kind of thing you usually call "i", "j"...). When someone stole my code, they didn t gone throught all the code and left the variable untouched. That was my signature. – DrakaSAN May 05 '14 at 14:58
  • @DrakaSAN I like that idea, especially if it's for non-important stuff :) – MikeFoxtrot May 05 '14 at 15:32
  • @TheFlyingEngineer: the only downside is that you need to plan to use this method from the beginning of the year, so that you can do the "Pick a file" to the teacher at that moment. – DrakaSAN May 05 '14 at 15:37
  • 29
    Why are you asking us? **Ask your professor or TA what appropriate behaviour is at your school**. – Eric Lippert May 05 '14 at 15:58
  • 6
    This is an application of [steganography](https://en.wikipedia.org/wiki/Steganography). Normally the real-world applications involve hiding messages in sound, images, or other lossy formats, but the general case is applicable here. The accepted answer is a good one but I would recommend learning about steganography as well. –  May 05 '14 at 17:26
  • @JohnGaughan will look into it... using a bit of DrakaSan's idea of variables, you could selectively skip letters (i.e. wrdlist --> missing an 'o') to encode a message without looking too obvious :) – MikeFoxtrot May 05 '14 at 17:29
  • You should definitely heed @EricLippert's advice and ask. At my university, where I've TA'd, another student using your code for an assignment is an automatic fail for both of you. This is regardless of whether they had your permission to do so; it is your duty to protect your own solutions. I'd not be surprised if things worked similarly at your school. – evilcandybag May 06 '14 at 01:18
  • 2
    How about just posting subtly broken code? – Benjol May 06 '14 at 05:21
  • What language are you coding in? Might make a big difference in the techniques available to you. – asteri May 07 '14 at 00:10
  • @JeffGohlke Python – MikeFoxtrot May 07 '14 at 21:42

10 Answers10

44

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!

Stas Bichenko
  • 3,689
  • 4
  • 24
  • 32
  • good suggestion but maybe a little overkill for a first year student :) – MikeFoxtrot May 05 '14 at 10:18
  • Github is very accessible! Try it out, it'll hold your hand during installation and creation of your first repo. I truly regret that I haven't started using Github earlier, and I'm sure you'll see very soon that your development process is greatly improved by it. – Stas Bichenko May 05 '14 at 10:40
  • 26
    @exizt - While this is a good idea after a school environment. I have my doubts that most formal situations within a school environment would accept this because in the end your still sharing your work with other students. **Its best to leave your school work your own ( and yours alone ) until after you have recieved a grade for it.** – Ramhound May 05 '14 at 10:55
  • @exizt just did, looks a very interesting.... :) – MikeFoxtrot May 05 '14 at 11:36
  • @Ramhound Perhaps I'm not familiar with the realities of some school environments. What's wrong with "sharing your work with other students"? – Stas Bichenko May 05 '14 at 14:04
  • 4
    @exizt - Professors are worried about cheating. Unless the professor says you can work with another student they normal have an expectation that you won't burrow code from your peers. If you need with the program there is an expectation of you going to the TA and/or professor not your peers.Which is the reason I suggested keeping your work to yourself until you recieve a grade. While its all warm and fuzzy the author wants to help his peers its not his problem they can't do the work without help. He can help just don't have evidence of such a deed If he wants to sit there and explain something – Ramhound May 05 '14 at 15:01
  • This is outright giving the other students the assignment. If caught, you would have been expelled from my college for cheating. The public log doesn't matter; it's trivial to change variables and other such conventions without understanding the logic behind the code, making it harder to spot/compare automatically. – Izkata May 05 '14 at 17:21
  • 4
    How would this resolve the original author? The person stealing your code could simply claim that they wrote it before your github checkin, and that you stole it from them. I don't see this addressing the problem in the question. – Adam Davis May 05 '14 at 19:19
  • 7
    Having TAed at my university, I know for a fact (and from watching it happen) that following this answer will get you cited for academic misconduct. I'm not aware of any university policy in my country (Australia) which distinguishes between the copyer and copyee with regards to plagiarism, and I doubt it would be substantially different anywhere else. It's much safer to keep your code to yourself! – sapi May 05 '14 at 19:29
  • 2
    Git allows the commit to set any timestamps that it wants. So I doubt you can rely on a git repo for any sort of evidence. – Zan Lynx May 05 '14 at 22:28
  • Even if you don't use Github (for all the legal and social reasons mentioned) getting in to the habit of using revision control is a good thing. It will give you a personal log of your progress, as well as the ability to easily recover to past revisions. If you write papers in TeX (or Markdown or ASCIIDoc, or...) you can use version control for those as well. For personal use and very low ceremony I would recommend starting with [fossil](http://www.fossil-scm.org/), but Git, Hg, and others will also suit. – RBerteig May 06 '14 at 01:36
  • 2
    Given that you can fake commit dates and all, I don't see how having a public log helps at all. – Lie Ryan May 06 '14 at 05:01
  • This is pointless: at most it might prove you did it by date X. If this was valid, it would mean that if you **didn't** do it, someone else could get your code, change the name, upload it, and then "prove" _they_ are the original author. Makes no sense. – o0'. May 06 '14 at 09:58
  • Alternatively, you could submit a hash of your code to pastebin (or whatever), if you wanted proof without actually sharing the code. Make sure you keep an archive of the code from when it was hashed so you can reproduce it later. – Muhd May 07 '14 at 01:34
  • Although that still wouldn't prove that you are the original author, as others have mentioned... and even if you could prove it, many universities do not allow sharing code anyways. – Muhd May 07 '14 at 01:44
14

"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.

jwenting
  • 9,783
  • 3
  • 28
  • 45
  • Bingo. The first rule of tutoring is that you should help people find solutions on their own. If you don't want people stealing your code, don't give them the code. If you want to help them, publish hints, lists of helpful algorithms & data structures or high-level descriptions of the solution. – Sean McSomething May 06 '14 at 05:21
  • 2
    There’s much to be gained from code-level collaboration. 1) Practice explaining code to others 2) Building working relationships 3) Learning classmates’ talents 4) Learning from classmates when you don’t have the best solution. Groups who pool effort will outperform stars on islands. Fellow students will always be frenemies; OP is trying to get the most from the friend side while mitigating against the occasional enemy side. – duozmo May 06 '14 at 17:48
  • @duozmo nothing wrong with working together (IF the assignment allows it of course), long as you don't end up doing someone else's work for them. And no, my fellow students were never enemies when I was in university. At worst they were competitors for the nicest assignments. – jwenting Nov 11 '14 at 14:55
7

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)

7

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?
  • 6
    I wouldn't depend on something like this - if they're using his code, changing around variable names and order would be an obvious step to avoid getting caught copying. – thegrinner May 06 '14 at 17:14
6

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.
rbaleksandar
  • 271
  • 2
  • 7
  • These are all very good points! I haven't considered them at all in my answer. – Stas Bichenko May 05 '14 at 15:17
  • thanks for the concern, good points :) we're allowed to collaborate with others on the tasks but i don't want people copypasting the of my code for their assignment if i share some of it. – MikeFoxtrot May 05 '14 at 15:34
4

Cartographers have the same problem. A couple techniques:

  1. Introduce an improbable deviance from your language's traditional style, e.g. always have imbalanced spaces around operators

    if (lefthand== righthand)

  2. Scatter no-ops throughout your code, if they're part of the language you're using.

    lefthand = righthand;;

duozmo
  • 141
  • 3
  • (1) would fall apart if students are using something like Eclipse's auto-formatter. (2) with the NOPs is a nice one. – Richard Le Mesurier May 06 '14 at 06:40
  • How would you prove people have been copying on you and not the other way around? – Pierre Arlaud May 06 '14 at 07:33
  • 2
    @ArlaudPierre as one person previously said the trick is too use something like this for all programs from the beginning of the year, so that you can prove that you did it intentionally and the other person did not. – MikeFoxtrot May 06 '14 at 07:52
  • The first one is *blech* and, as pointed out, is easily defeated by a formatter; the second will give warnings in any good IDE. – David Conrad May 06 '14 at 15:31
3

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.

Eric J Fisher
  • 648
  • 5
  • 11
1

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.

Andy Dent
  • 211
  • 1
  • 6
1

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.

david.pfx
  • 8,105
  • 2
  • 21
  • 44
  • 2
    I'm actually going to discourage this. While A commend the creative way of tackling this problem these can lead to habits no professional wants to deal with. The amending a letter etc isn't bad but intentionally misspelling is a terrible habit to have when you get to working in teams. "Oh hey it's in the 'common' folder", "I am not finding any folder named 'common'", "Oh crap I mean 'commom'", "... is that 'com_mom', 'comm_mom', 'commmom', or 'commom'..." – Eric J Fisher May 06 '14 at 13:56
  • You obviously haven't worked with certain out-sourcers for whom English is not the first language. I counted 11 different spellings of the word 'announcement' (at least that's what I think they were). – david.pfx May 06 '14 at 14:05
  • I have, "Commom" came to be in that exact manner. It's been something we've lived with until it pisses off someone enough to fix whatever the offending word of the day is. Adding to this problem for the purpose of standing out as "your signature" is cringe worthy – Eric J Fisher May 06 '14 at 14:45
  • @RualStorge: Ah. An ingenious answer, but not one to trot out at an interview perhaps? – david.pfx May 06 '14 at 15:08
  • 1
    No, but then again there are many many things one does not say in an interview process. Such as entering a company with poor project management... One doesn't say they plan to actively use subtle subterfuge and borderline insubordination to improve the company's practice and policies, but here we are ;) – Eric J Fisher May 06 '14 at 18:52
0

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.

sanepete
  • 111
  • 1
  • However this should lose you marks as the programs are not as good as they should be and also the TAs won't be able to read them – mmmmmm May 06 '14 at 14:02
  • Your grade will be penalized for this typically if noticed. No one likes when you go to search of "logRepository" only to find it's actually "1ogRepository" it just makes you look bad. – Eric J Fisher May 06 '14 at 14:42
  • That's told me. I'll get my coat. – sanepete May 07 '14 at 09:11