Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

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.

share|improve this question
66  
don't share code but share ideas –  ratchet freak May 5 at 9: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 5 at 14:58
27  
Why are you asking us? Ask your professor or TA what appropriate behaviour is at your school. –  Eric Lippert May 5 at 15:58
6  
This is an application of 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. –  Snowman May 5 at 17:26
2  
How about just posting subtly broken code? –  Benjol May 6 at 5:21

10 Answers 10

up vote 39 down vote accepted

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!

share|improve this answer
25  
@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 5 at 10:55
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 5 at 15:01
3  
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 5 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 5 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 5 at 22:28

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

share|improve this answer
    
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 6 at 5: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 6 at 17:48

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)

share|improve this answer

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?
share|improve this answer
3  
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 6 at 17:14

I thing is 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.
share|improve this answer
    
These are all very good points! I haven't considered them at all in my answer. –  exizt May 5 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 5 at 15:34

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;;

share|improve this answer
    
(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 6 at 6:40
    
How would you prove people have been copying on you and not the other way around? –  Arlaud Pierre May 6 at 7: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 6 at 7: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 6 at 15:31

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.

share|improve this answer
    
You want "versus", not "verses". Unless you and Bob are writing poetry. ;) –  David Conrad May 6 at 15:34
    
@DavidConrad Thank you, code is poetry after all ;) corrected accordingly. –  RualStorge May 6 at 18:46

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.

share|improve this answer
1  
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'..." –  RualStorge May 6 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 6 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 –  RualStorge May 6 at 14:45
    
@RualStorge: Ah. An ingenious answer, but not one to trot out at an interview perhaps? –  david.pfx May 6 at 15:08
    
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 ;) –  RualStorge May 6 at 18:52

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.

share|improve this answer
3  
There already is an language for it - en.wikipedia.org/wiki/Whitespace_(programming_language) –  Ondrej Svejdar May 6 at 7:53

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.

share|improve this answer
    
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 –  Mark May 6 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. –  RualStorge May 6 at 14:42
    
That's told me. I'll get my coat. –  sanepete May 7 at 9:11

protected by MichaelT May 6 at 12:15

Thank you for your interest in this question. Because it has attracted low-quality answers, posting an answer now requires 10 reputation on this site.

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.