in reply to Re: my first japh
in thread my first japh

thanks davido, i forgot to post that. Should be Rot-26 if it was to be used in any sort of sensitive situation.
meh.

Replies are listed 'Best First'.
Re^3: my first japh
by davido (Cardinal) on Nov 21, 2005 at 05:36 UTC

    Rotation cyphers are not useful as meaningful encryption, only as content obfuscation. Using tr/// is the standard method of implementing Rot13 in Perl (at least to the extent that there actually exists standard ways of doing anything in Perl). Here's an example from perlfilter:

    WRITING A SOURCE FILTER IN PERL
    The easiest and most portable option available for creating your own source filter is to write it completely in Perl. To distinguish this from the previous two techniques, I'll call it a Perl source filter.

    To help understand how to write a Perl source filter we need an example to study. Here is a complete source filter that performs rot13 decoding. (Rot13 is a very simple encryption scheme used in Usenet postings to hide the contents of offensive posts. It moves every letter forward thirteen places, so that A becomes N, B becomes O, and Z becomes M.)

    package Rot13 ; use Filter::Util::Call ; sub import { my ($type) = @_ ; my ($ref) = [] ; filter_add(bless $ref) ; } sub filter { my ($self) = @_ ; my ($status) ; tr/n-za-mN-ZA-M/a-zA-Z/ if ($status = filter_read()) > 0 ; $status ; } 1;

    All Perl source filters are implemented as Perl classes and have the same basic structure as the example above.


    Dave