If I were to write a security application and sell it or "opensource" it, how would I avoid writing the same code coincidentally if I cannot review source code of other programs out there? (and replace matching code)

I understand citing source can prevent plagiarism, but even then, how would a company know without access to their business rival's source code?

  • 3
    How would the owner of closed-source code be able to prove, in a court of law, that you illegally copied their source code which you do not have access to?
    – user22815
    Commented Apr 3, 2017 at 21:42
  • The answer is every jurisdiction is slightly different in terms of how this might play out in a legal scenario. Your best bet is to discuss with a lawyer who specializes in IP law in your jurisdiction as to what strategy to use while developing your software.
    – user22815
    Commented Apr 3, 2017 at 21:45
  • 2
    Your question is unclear. Where is the copyright infringement in your example? Commented Apr 3, 2017 at 23:16

1 Answer 1


You can't "coincidentally write the same code" any more than you can coincidentally happen to write Shakespeare's Hamlet. That is, the probability's vanishingly remote. Of course, you're bound to use the same ideas, etc. But ideas can't be copyrighted (at least not in the US), although they can be patented (in the US). For example, gif was patented until its patent expired circa 2004, and no matter how original your gif code was, it would have been a patent violation until then. So if you work in the US, you can't code any still-patented security (or any other kind of) algorithms.

But, as above, the probability that any non-trivial (e.g., anything much beyond "Hello, World.") program looks byte-for-byte so much like another program that courts would interpret the similarity as copyright infringement is vanishingly remote. As long as you actually are designing and writing the program yourself, there's virtually no worry whatsoever.

  • To be nitty: even when you live in the US, you can code patented algorithms. You just have a certain risk to get sued if a patent holder gets notice of that, and you do not hold enough patents on your side to sue him, or find a settlement out of court.
    – Doc Brown
    Commented Apr 4, 2017 at 12:26

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