Link to home
Start Free TrialLog in
Avatar of oucher
oucher

asked on

reversible crypt?

I'm looking for a method of very simple encryption:

1) It must be able to encrypt a whole text file
2) The file must be decryptable using the same key
3) Security is not a big concern, mainly I just want the files to not be readable at first glance
3) I don't want to install any modules, .pm files, etc.

The reasoning behind this is that I have some files that I access with a script over the web, but the server they're stored on is a friend's, not mine.  I don't want him reading the files, but he's not the kind who would spend a lot of time trying to crack codes, so something very simple would do.  Any ideas?
Avatar of samay
samay

replace characters by certain others..
and put it back..
a->b
b->b
c->d
...

z->a

Here's a simple rot13'er:

while (<>) {
    tr/[a-zA-Z]/[n-za-mN-ZA-M]/;
    print;
}

The same code will encrypt as well as decrypt the text. Of course, it handles only alphabetic characters. If you want it to handle numeric and other special characters, you need to extend the patterns above.
Avatar of oucher

ASKER

Thanks prakashk, that's the kind of thing I'm looking for.  For adding numeric and symbolic characters, is there some easy way to add or subtract do it using ASCII numbers?  Is there a Perl function that will convert a number to a char and vice versa?
ASKER CERTIFIED SOLUTION
Avatar of prakashk021799
prakashk021799

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of oucher

ASKER

Thanks a lot!