caesar() in linux ?

I am trying to rebuild some of my old perl programs into linux.
I have read about caesar and rot13, but I have no man pages on them.

Is there a library or something I must do?
 

Thanks

Rockman
LVL 10
rockmansatticAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

wesly_chenCommented:
0
jdfoxCommented:
Here's a good man page for doing source filters in perl on linux, with example code for the caesar cypher rot13:

http://www.die.net/doc/linux/man/man1/perlfilter.1.html

0
rockmansatticAuthor Commented:
Sorry, after reading my question, I didnot explain properly.

I am actually looking for a function caesar() or ROT() or linux/unix/fedora...
I have several perl scritps that I want to redo, not just run in unix enviroment.

I need a simple example of a working ROT or Caesar txt file , something like this



#!/bin/ah
echo "filename"; filename = read()

% tr "[a-z][A-Z]" "[n-z][a-m][N-Z][A-M]" < filename


blah blah blah

Thanks
Rockman
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

wesly_chenCommented:
Hi

Is this what are your looking for?
------
package CaesarVMethod;
  use base qw(Template::Plugin::VMethods);
  @SCALAR_OPS = ( "caesar",
                  "rot13"   => sub { caesar($_[0],"13") } );
  sub caesar
  {
    $string = shift;
    $string =~ tr/A-Za-z/B-ZAb-za/ for 1..$_[0];
    return $string;
  }
------

Wesly
0
rockmansatticAuthor Commented:
that looks like what I need, but how do you use it?

uped pts
Thanks
0
jdfoxCommented:
That snippet is calling the VMethods plugin module for Template Toolkit, a template processing system intended mainly for web content:
http://www.template-toolkit.org/

That's why "use base" is calling it from the Template package on the second line.

Here's the CPAN page for VMethods on CPAN for more info:
http://search.cpan.org/~markf/Template-Plugin-VMethods-0.03/lib/Template/Plugin/VMethods.pm

So if you're not using Template Toolkit, that will probably be of limited use for you.

These scripts will both decrypt:
http://www.sentex.net/~ajy/perl/caesar
http://search.cpan.org/~juerd/Crypt-Caesar-0.01/Caesar.pm

Do you need to encrypt too?
Here's a good simple Perl script to encrypt and decrypt Caesar:
alphabet_lower=abcdefghijklmnopqrstuvwxyz
alphabet_upper=`echo $alphabet_lower | tr "[a-z]" "[A-Z]"`
function rotx() {
  local offset=`expr $1 % 26 + 1`
  test $offset -lt 1 && offset=`expr 26 + $offset`
  rot_lower1=`echo $alphabet_lower | cut -c$offset-26`
  rot_lower2=`echo $alphabet_lower | cut -c-\`expr $offset - 1\``
  rot_upper1=`echo $alphabet_upper | cut -c$offset-26`
  rot_upper2=`echo $alphabet_upper | cut -c-\`expr $offset - 1\``
  echo "${rot_lower1}${rot_lower2}${rot_upper1}${rot_upper2}"
}
function caesar() {
  local offset=$1; shift
  echo $* | tr ${alphabet_lower}${alphabet_upper} `rotx $offset`
}

You can encrypt a message with this using the following syntax:
caesar <s> your message here ...

example: caesar 35 only you can read this...
xwuh hxd ljw anjm cqrb...

Or you can decrypt it with a -s.
example:  caesar -35 xwuh hxd ljw anjm cqrb...
only you can read this...

More info here:
http://www.maenad.net/geek/gpg/encryption_explanation.txt
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Linux

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.