in reply to encryption golf (one time pad)

perl -0777pe"$_^=<>"

Depending on how you count, it may not be shorter, but it certainly wins points for craziness. I wish I had a "v" there, then I'd be pointing in every direction (< ^ v >).

Update: s/377/777/. Thanks Corion.

Replies are listed 'Best First'.
Re^2: encryption golf (one time pad)
by mr_mischief (Monsignor) on Mar 17, 2008 at 09:25 UTC
    Very nice! Using the command-line parameters was a big win.

    I was going for the shortest solution in a source file without counting the shebang line, but I certainly didn't specify that as a rule. I think it's good I didn't, because this is a nice solution.

    Mine's more aesthetically pleasing to my eyes, but that's entirely subjective and I'm probably biased anyway. I also think mine's easier to commit to memory, but that's subjective too. You might find completely different things easier to memorize. Neither has anything to do with golf, but I thought they were nice touches considering the tight controls on free speech and on encryption software in some places. I know if I'm putting it on a shirt or into my skin, nice looking solutions get at least part of the consideration.

      I was going for the shortest solution in a source file without counting the shebang line

      If so, then mine is 6 to your 18.

      #!/usr/bin/perl -0777p $_^=<>

      I think your method of counting isn't appropriate, though.

      Mine's more aesthetically pleasing to my eyes, but that's entirely subjective and I'm probably biased anyway

      No, I agree. I did say mine was crazy.

        If you construct the shebang line like that, though, perhaps the "-0777p" should be counted? You'd still have a shorter solution, either way.

        What's really funny is I wrote mine in response to a 51-character one on a site all about trivially short encryption implementations, and now you go and trim 1/3 or 2/3 off of it again depending on how you count that.

        Update: s/0377/0777/ to match ikegami's update (Thanks, Corion).

        If so, then mine is 6 to your 18.

        According to the general Perl golf rules (which can be seen, for example, here, near the bottom), "If you use options on the #! line, the options themselves are counted, including the leading space and -." (emphasis in the original). So  -0777pe"$_^=<>" would be 16.

        --
        David Serrano