in reply to Rot13 Source Jumbling

Basically you want something along the lines of:

# # Warning: untried code # my $message = "Blah!"; my (%translation); my $alphabet = join('', (a..z)); # Cheezy, but does 2 passes, performing a uc() in between foreach (0..1) { my $startchar = ord(substr($alphabet, 0, 1)); foreach my $c (0..25) { $translation{chr($startchar + $_)} = substr($alphabet, $_ - 13, 1); } $alphabet = uc($alphabet); } # %translation now contains the value for each character # in ('a'..'z', 'A'..'Z') print("Old message: ", $message, "\n"); my @letters = split('', $message); my (@newmessage); while (@letters) { my $c = shift(@letters); $c = $translation{$c} if (defined($translation{$c})); push(@newmessage, $c); } $message = join('', @newmessage); print("New message: ", $message, "\n");

Others may know a better way to implement it, and I look forward to seeing their postings. Hope it at least helps.

Replies are listed 'Best First'.
Re: Re: Rot13 Source Jumbling
by ibanix (Hermit) on Dec 07, 2002 at 03:47 UTC
    Others may know a better way to implement it, and I look forward to seeing their postings

    Does it count if I use my Capt. Crunch magic decoder ring?  :-)

    $ echo '$0 & $0 &' > foo; chmod a+x foo; foo;
Re: Re: Rot13 Source Jumbling
by Anonymous Monk on Dec 07, 2002 at 04:03 UTC
    Thank you very much - But would this code work for the script itself when executed? For example, the script would be all coded and I would need to run it:
    #!/usr/bin/perl use DESRAMBLER; cevag "Pbagrag-glcr: grkg/ugzy\a\a"; cevag "uryyb jbeyq";

    Thats a simple hello world script, but I have no idea how to descramble it at run time without using filter:util modules.