Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Crypt::Rot26

by jeffa (Bishop)
on Sep 21, 2001 at 04:23 UTC ( [id://113756]=CUFP: print w/replies, xml ) Need Help??

i got bored - hope you enjoy >:)

"you need coolin', baby i'm not foolin' . . ." okay, so i am ;)


=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;

Replies are listed 'Best First'.
Re: Crypt::Rot26
by Dragonfly (Priest) on Sep 25, 2001 at 20:32 UTC
    Thank you, jeffa. I've been looking for a module to do this sort of high-powered, uncrackable encryption for quite some time. For the sake of security I will, from now on, be using this program to encrypt all of my posts to PerlMonks.
Re: Crypt::Rot26
by ikegami (Patriarch) on Oct 01, 2010 at 18:43 UTC

    Is it compatible with Crypt::CBC? Our policy requires that we use salted encryption, and we let CBC do that rather than inventing the wheel.

    Encrypt data with TWICE the power of Rot13!!

    Any comments as to how Rot26 compares with 3DES, which encrypts three times?

      The GREAT ikegami snidely remarks: Any comments as to how Rot26 compares with 3DES, which encrypts three times?

      Yeah, bend over and I'll show ya.

Re: Crypt::Rot26
by jffry (Hermit) on Oct 01, 2010 at 18:09 UTC

    Shouldn't $bonham be $young or at least $larson?

Re: Crypt::Rot26
by Anonymous Monk on Sep 30, 2010 at 18:02 UTC
    Awesome script. Works great for me too. But can you add a function that will allow me to digitally sign my text using ROT26 too?
Re: Crypt::Rot26
by Anonymous Monk on May 27, 2012 at 00:35 UTC

    Thank you!

    i really needed this! just worried it may be a performance hit..

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: CUFP [id://113756]
Approved by root
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (3)
As of 2024-04-19 17:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found