views:

603

answers:

16

For what purposes would you want to obfuscate your code? I have not run into any real purposes other than participating in contests, but I am sure there must be some intelligent and useful reasons for obfuscating source code.

Why, in general, do you want or need to obfuscate your code?

What real-life applications does obfuscation have?

+9  A: 

It slows down (but does not stop those that are determined) from reverse-engineering your code.

Robert Harvey
+1  A: 
  1. It can slow down malicious hackers trying to pirate or otherwise modify your software in an unauthorized or undesirable way. Not by much, but if you're worried about a street release date, a few days or hours can matter.

  2. This isn't ethical, but having mission-critical code that only you understand is one way some programmers ensure their job security.

sangretu
+7  A: 
  • make theft of intellectual property more difficult
  • security through obscurity
  • bandwidth minimization, in cases like javascript minify
RedFilter
Are you demonstrating an obfuscation algorithm? ;)
eyelidlessness
Nevermind, you edited.
eyelidlessness
character reduction algorithm.
Aiden Bell
haha, no some funky formatting issues, now fixed :)
RedFilter
+5  A: 

Let's say you have a contract with a company to produce some software. They are a pain to work with and basically made your life a living hell. Part of the contract says that after the project is done you must turn over all source code... :D

BoltBait
Go to jail, do not pass go, do not collect a community card.
Aiden Bell
Hey! If the source provided compiles, I have completed my end of the bargin. Of course, I wouldn't expect to do any future work with that company.
BoltBait
I would expect them to charge the cost of rewriting it and maintaining it until the damage is rectified to you however :P
Aiden Bell
... not that you *would* ever work for them again.
Brad Gilbert
@Brad, I dunno, he might stipulate future contracts in his ransom note!
Aiden Bell
This approach does, however, cover your ass in the likely event they delay payment, or start contesting the invoice, or flat-out refuse to pay (I've seen that happen too often once these types get the source code)... -R
Huntrods
this is interesting, would handing in obfuscated source code be illegal? any lawyers out here?
Junier
@Junier - (IANAL, but) It's going to depend entirely on how your contract is worded. It's possible that your contract specifically says you can't, but it's not a terribly common scenario, so it might not be in the contract at all, therefore being perfectly legal.
Chris Lutz
+1  A: 

If you launch an application whose logic is in the clear then obfuscation can prevent, to some small degree, competitors swiping your logic verbatim.

When you are a new site, beating the "me too" crowd can be important.

But the prevention is weak and not worth the time IMHO.

Aiden Bell
+1  A: 

Code obfuscation is usually applied to interpreted languages such as php where source code is not compiled and has to be distributed to the end user. In reality, obfuscation is breakable and I use it only to keep honest people honest. You know, it's easier to get something cracked than to actually reach for the credit card.

Ilya Biryukov
+6  A: 

Code obfuscation became popular around the time perl was first released. It was really an artifact of making the code more efficient. In those early days of yore there was a flame war of sorts between the established "c" programming community and the "renegade" perl advocates. The old-school c guys obviously trumped the perl guys by siting performance. The perlers (?) in response began coming up with performance hacks without regard to readability. Hence,obfuscation. This of course is no longer necessary since the perlers (?) conceded performance a long time ago the the c'ers (nice piun huh?). Obfuscation was NEVER used for security purposes that I've seen. In fact if you would suggest it as some kind of security measure people would laugh you out of the room. The hackers trying to circumvent security are in general very knowledgeable of the languages and toolsets they are targeting. Thats what makes them so successful. Obfuscation is not in any way a defense against them.

ennuikiller
+1000 if I could.
Chuck
I like the obfuscation in your answer text. Makes it very hard to read. Ever heard of the Enter key?
Ash
+3  A: 

Read here

The goal of obfuscation is to create confusion. As confusion builds, the ability of the human mind to comprehend multi-faceted intellectual concepts deteriorates. Note that this precept says nothing about altering the forward (executable) logic – only representing it incomprehensibly. When a well-written obfuscator tool goes to work on readable program instructions, a likely side effect is that the output will not only confuse a human interpreter, it will break a decompiler.

Ariel
+1  A: 

The most important use is to reduce the size. I always use it on Javascript and on Java applications for mobile phones (j2me).

Some obfuscators can also do some small optimizations.

rjlopes
A: 

As a concrete example, take a look at the script behind gmail. This is obfuscated primarily to stop some enterprising hacker creating an alternative front-end that talks to the gmail servers.

A secondary - though important - benefit is script size reduction.

wildcard
+3  A: 

Real life use for obfuscation?

I dunno, the writer of the code base i'm working on seems to enjoy it!

Janie
A: 
Huntrods
A: 

Obfuscation is not going to beat a determined hacker or protect your top secret algorithm but in most cases that is not the point. Traditionally it only needed to be good enough to make a company pay for software support and updates rather than taking the effort to de-obfuscate and maintain the software themselves.

I first came across obfuscation in the early days of Unix when most C programs had to be delivered in source form because of the plethora of different cpu architectures and the lack of clever linkers or common object file formats.

With the rise of interpreted languages obfuscation is now probably used more than ever for commercial software.

Dipstick
+1  A: 

We sell obufuscators to people designing circuits in VHDL and Verilog. Because such designs are generally fairly big, there's a lot to obfuscate (often tens of thousands of lines), and trying to reverse engineer these is extremely hard.

Ira Baxter
A: 

Code obfuscation has limited commercial application. It can however help to sharpen a developers' toolbox in a unique way. Obfuscated code serves as an extreme counterpoint to clean well documented code design.

galaxywatcher