1
\$\begingroup\$

There are numerous reasons for trying to obfuscate input. These include preventing decompiling, and being a nuiscance.


With this in mind your challenge should your choose to accept it is to write a meta-obfuscator. Your code must in some Language X receive input as a String, and output a program in language X that outputs the input String.
Rules

  1. Standard loopholes disallowed
  2. It should be hard to tell whether the output prints anything (I.E the code should be heavily obfuscated)
  3. Your program should be testable
  4. Cryptographic approaches are permitted, but it should not be obvious.
  5. Try to submit an interesting solution as this is a popularity contest


Winning Criterion
Although it is up to you to decide which question deserves your upvote. Here are the guidelines.

  1. Hardest to reverse engineer output based on the source code (i.e most encrypted/obfuscated)
  2. Effort and quality of answer


tl;dr Output a program which prints the input, but make it hard to understand what is going on. Although many people have discussed this (especially for javascript) and even python. I have seen no formal repository of such programs in any arbitrary languages.

\$\endgroup\$

closed as off-topic by Dennis Jul 2 '16 at 23:10

  • This question does not appear to be about programming puzzles or code golf within the scope defined in the help center.
If this question can be reworded to fit the rules in the help center, please edit the question.

  • \$\begingroup\$ This conversation has been moved to chat. \$\endgroup\$ – Dennis Jul 2 '16 at 23:17
  • \$\begingroup\$ This looks like it's trying to be an underhanded challenge without explicitly being an underhanded challenge. An underhanded underhanded challenge perhaps, which makes it doubly off-topic. \$\endgroup\$ – Mego Jul 3 '16 at 1:42
2
\$\begingroup\$

Java

Just out of curiosity I decided to write a simple block of code that outputs code that does not look obfuscated. Here is the generator code

package metaobfuscate;

import java.util.Random;
import java.util.Scanner;

/**
 *
 * @author rohan
 */
public class MetaObfuscate {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        String s = (new Scanner(System.in)).nextLine().toLowerCase();
        int i = 0;
        int numChar = s.length();

        String randomlyGenerated;
        String alphabet = " abcdefghijklmnopqrstuvwxyz!?.";
        do {
            Random rand = new Random(i);
            randomlyGenerated = "";
            i++;
            for (int j = 0; j < numChar; j++) {
                randomlyGenerated += alphabet.charAt((int) (rand.nextDouble() * alphabet.length()));
            }
        } while (!s.equals(randomlyGenerated));
        i--;
        System.out.println("import java.util.Random;\n//Simple demonstration of generating random characters");
        System.out.println("public class RandomNessTest {");
        System.out.println("\t//args are the command line arguments");
        System.out.println("\tpublic static void main(String[] args){");
        System.out.println("\tRandom rand = new Random(" + i + ");//replace the seed with whatever seed you want");
        System.out.println("\t//the seed was generated by random keyboard mashing");
        System.out.println("\tString alphabet = \" abcdefghijklmnopqrstuvwxyz!?.\";");
        System.out.println("\tfor(int i = 0;i<" + numChar + ";i++)");
        System.out.println("\t\tSystem.out.print(alphabet.charAt((int)(rand.nextDouble()*alphabet.length())));");
        System.out.println("\t//print out a few random characters");
        System.out.println("\t}\n}");
    }

}

It takes in whatever string you wish to obfuscate and outputs a program that looks reliable as output. It takes exponential runtime with larger strings, but it works great for strings of length 1-5. The outputted program claims to be a tutorial, and is even formatted nicely!

import java.util.Random;
//Simple demonstration of generating random characters
public class RandomNessTest {
    //args are the command line arguments
    public static void main(String[] args){
    Random rand = new Random(2727915);//replace the seed with whatever seed you want
    //the seed was generated by random keyboard mashing
    String alphabet = " abcdefghijklmnopqrstuvwxyz!?.";
    for(int i = 0;i<5;i++)
        System.out.print(alphabet.charAt((int)(rand.nextDouble()*alphabet.length())));
    //print out a few random characters
    }
}
\$\endgroup\$

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