I'd like to give my Java sources to another Java developer so that he can study them while he should be unable to compile them. I am looking for a simple but effective one-way algorithm making my sources uncompilable. I hope I explained the goal clearly.
My first idea was parsing all my sources and making all my method names random mixed case:
private double getAvailableCash() --> private double gEtaVailabLEcASh()
It is quite simple and not so easy to redo, not impossible though. Can you suggest me some other, hopefully better ways?
Update:
Many of you commented/asked about the reason that someone would like to do this. Suppose the following scenario: you have to prove that you are ready with a good quality solution before the other developer pays you, but you do not trust him for a good reason. Showing a working compiled demo is not enough because he wants to see the way you worked. If you gave him the compilable source it is possible that you would not get your payment as soon as you would without giving the source..
Anyway, it seemed a very interesting, funny problem to me and seeing the many comments and answers even for many of you.. :-)
I don't know why you would want to do this but anyway...
perl -pi -e 'undef $/; s,^,\00,' $(find -name "*.java")
You will not even have to change code!
What this does is add a single byte, which is 0, to the beginning of each file named *.java. And yes, this is enough to make a file not able to compile!
To undo:
perl -pi -e 's,^\00,,' $(find -name "*.java")
A little more explanation about $/: it is the input separator which perl uses to read from streams. It is set to a newline by default, which is why normally perl reads line by line. Here it is defined to nothing, which means it reads the whole file at once. If it is defined to an empty string, it will read paragraph by paragraph. And you can define it to anything you like.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With