in reply to Short & Sweet Encryption?
It does not need to be secure,If it really doesn't need to be secure, merely a little obscure to discourage the curious and minimally motivated, you can get a quick and easy result in the same number of charactes, using just a little scrambling. Transform each character to a different character using tr///, and scramble the characters using an array slice. It should be fairly fast as well.
Update: Here's a very simple code implementation if that's helpful.
use warnings; use strict; my $in = 'Simpletestxy'; my $tr_ed = $in; $tr_ed =~ tr/A-Za-z1-9/1-9a-zA-Z/; #complicate and add chars to the tr/// as you wish # 0 1 2 3 4 5 6 7 8 9 10 11 my $out = join '',(split '',$tr_ed)[qw(5 6 4 2 9 10 3 7 11 1 8 0)]; my $back = join '',(split '',$out )[qw(11 9 3 6 2 0 1 7 10 4 5 8)]; $back =~ tr/1-9a-zA-Z/A-Za-z1-9/; print "in=$in, tr_ed=$tr_ed, out=$out, back=$back\n";
2nd Update: Xor with a pass phrase as syphilis uses can be used instead of the tr/// step in the code above, it's another way of doing and expressing the translation. Use of tr/// has an advantage if you want the $output confined to printable characters, otherwise, just decide which is easier for you to read.
|
---|