If someone has some kind of secret code, they better keep it secret, because once it is leaked, it is as good as "common knowledge.

This is essentially where Trade Secret law comes in. It's your work for as long as you can keep it a secret, but you lose it all if it becomes public. It's almost the opposite of a patent, which says (in theory, anyway) you have to detail everything about the work so that others can reproduce it, but you get to be the sole owner of the work for a limited time.

There are a few bizzare circumstances where (for instance) the NSA has a trade secret on some encryption technique, but if it ever becomes public, they automatically get a patent on it. Also, RSA claimed a trade secret on the RC4 stream cipher for years, until somebody anonymously posted code for it on USENET. They sometimes threaten to sue people using it without permission, even though their trade secret protection is clearly gone (even though they would lose the lawsuit, no company is willing to pay to go through the court system to fight them). I haven't heard of recent examples of them doing this, though.