in reply to Re: One-liner to rule them all...
in thread One-liner to rule them all...

What I have so far after doing some research:

tr/a-z/x-za-w/

Now just to feed this into system() call... or backticks?
Also, to answer your questions:
1. I'd like this in perl since perl is essentially guaranteed to be installed on a *nix system.
2. Learning is great and I love doing it. Perl seems kinda cool, from what I've seen since yesterday.
3. perlop held many answers :)

Replies are listed 'Best First'.
Re^3: One-liner to rule them all...
by davido (Cardinal) on Jul 11, 2012 at 16:00 UTC

    I'm assuming that you're going to set up your one-liner such that the target string is held in @ARGV (A special variable documented in perlvar). That's one simple possibility. So $ARGV[0] will hold the first string passed on the command line. To bind your transliteration operator to $ARGV[0] you use the =~ operator like this: $ARGV[0] =~ tr/a-z/x-za-w/.

    Now $ARGV[0] holds the transliterated string, and all you need to do is pass it to system, just as you would pass any parameter to any function.

    If your target string contains whitespace you will have to wrap it in quotes that your shell respects.

    I still don't understand why this is useful. It's not really a form of security, and if the goal is to hide keystrokes, it is easy to unravel. Plus any system call will still show up in the process list.


    Dave

      Forgive my tardy reply.
      I've got it to this:
      perl -e "system(mystring =~ tr/a-z/x-za-w/r)"
      Where `mystring` is a hard-coded string.
      So I have a working solution, but is there anyway to obfuscate it further?
      To answer your question, I should have been honest from the beginning. I wanted this one-liner to do something cheeky... it's in a section of the README of the software I'm working on, as a treat for the dedicated reader.

        ...I should have been honest from the beginning.

        Yes, people volunteering help appreciate honesty in return. If you had told me from the beginning that you were working on an obfu, I wouldn't have been opposed, though I would have given you the recommendation that it's now taken a series of responses to finally get to: Learn Perl first. Learn to get your script to do what you want it to do without the complications of obfuscation. Once you get it all figured out from a functionality standpoint, then go ahead and play with obfuscating it on your own time.

        Good luck with your endeavour.


        Dave

        Well, then maybe you should have picked something a bit less trivial than ROT... if any of us saw your work, it'd be cracked by now.