=head1 NAME Crypt::Rot26 - Encrypt data with TWICE the power of Rot13!! =head1 SYNOPSIS use strict; use Crypt::Rot26; my $crypt = Crypt::Rot26->new(); my $bonham = 'whole lotta luv!'; my $crypted = $crypt->crypt($bonham); print $crypted, "\n"; print $crypt->decrypt($crypted), "\n"; =cut package Crypt::Rot26; sub new { my ($proto) = @_; my $class = ref $proto || $proto; my $self = { rot => 26, offset => { map { $_ => 97, uc $_ => 65 } ('a'..'z') }, }; bless $self, $class; return $self; } sub crypt { do_it(@_,'+'); } sub decrypt { do_it(@_,'-'); } sub do_it { my ($self,$str,$op) = @_; my $crypted = ''; my $rotation = $self->{rot}; foreach my $chr (split('',$str)) { if ($chr =~ /[A-Za-z]/) { my $offset = $self->{offset}->{$chr}; my $shift = eval "$offset $op $rotation"; $chr = chr((ord($chr) - $shift) % 26 + $offset); } $crypted .= $chr; } return $crypted; } 1;