Rot13(3) User Contributed Perl Documentation Rot13(3)NAMECrypt::Rot13 v0.6 - a simple, reversible encryption
SYNOPSIS
use Crypt::Rot13;
my $rot13 = new Crypt::Rot13;
$rot13->charge ("The quick brown fox jumped over the lazy dog.");
print $rot13->rot13 (), "\n";
print $rot13->rot13 (245.333), "\n";
print $rot13->peek (), "\n";
open (F, "/etc/passwd") or die "$!";
$rot13->charge (<F>);
close (F) or die "$!";
print $rot13->rot13 (-13);
while (<STDIN>) {
$rot13->charge ($_);
print $rot13->rot13 ();
}
$rot13->charge ('a' .. 'z');
foreach (0 .. 26) {
print $rot13->rot13 ($_), "\n";
}
DESCRIPTION
rot13 is a simple encryption in which ASCII letters are rotated 13
places (see below). This module provides an array object with methods
to encrypt its string elements by rotating ASCII letters n places down
the alphabet.
Think of it this way: all of the letters of the alphabet are arranged
in a circle like the numbers of a clock. Also like a clock, you have a
hand pointing at one of the letters: a. Crypt::Rot13 turns the hand
clockwise n times through 'b', 'c', 'd', etc, and back again to 'a', 26
turns later.
Crypt::Rot13 turns this hand for every letter of every string it con-
tains a given number of times, the default of which is 13, or exactly
half the number of letters in the alphabet.
PUBLIC METHODS
* Crypt::Rot13->new (@arguments)
This creates a Crypt::Rot13 object, which is a blessed array refer-
ence. Any arguments given to "new" define the array, which is
defaultly empty.
* Crypt::Rot13->charge (@arguments)
Any arguments given to "charge" define the array. If no arguments
are passed, the Crypt::Rot13 array will be empty. The arguments
can be non-strings; see the following example.
my $rot13 = Crypt::Rot13->new ({'foo' => 'bar'}, 111);
print $rot13->peek (), "\n", $rot13->rot13 (), "\n";
* Crypt::Rot13->peek ()
This dereferences and returns the Crypt::Rot13 object.
(In case you are wondering, the strange method names of "peek" and
"charge" are derived from my original conception of Crypt::Rot13 as a
magical device.)
* Crypt;:Rot13->rot13 ($degree)
Rotates ASCII alphabetical characters of each element of the array
degree times and returns the changed array without altering the
Crypt::Rot13 object. The degree can be negative and a fractional
part is ignored (to be precise, "chr" and "%" ignore it).
Degrees effectively equal to 13 are optimized to a "tr///".
Degrees effectively equal to 0 are optimized into a "peek".
A degree $d is "effectively equal" to 13 if "$d % 26 == 13".
LICENSE
Copyright (C) 1999-2000 Julian Fondren
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of MER-
CHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
BUGS
The algorithm of "rot13" isn't very easy to understand.
AUTHOR
Julian Fondren
SEE ALSOperl(1)rot13(1)perl v5.8.8 2000-04-21 Rot13(3)