Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"


by beretboy (Chaplain)
on Dec 02, 2001 at 04:27 UTC ( #128931=sourcecode: print w/replies, xml ) Need Help??
Category: Cryptography
Author/Contact Info
Description: A encryption algorithm. That I whipped up. Takes file name as command line argument, -d switch sets it into decrypt mode. Key can be anything but the longer the better.XIMP stands for XIMP Is Mucho Polyalphabetic. DISCLAIMER: This should by no means be taken seriously! It was simply an experiment! This is by no means real crypto and could be cracked by anyone with even limited knowledge of cryptography.

use strict;

my @wheel1 = qw( 8 4 6 6 3 3 8 4 );
my @wheel2 = qw( 1 2 4 6 3 8 8 9 5 1 6 1 7 2 8 1 );
print "KEY:";
chomp(my $key = <STDIN>);
my @wheel3 = map(ord, split //, $key);

my $file = @ARGV[0];
$/ = undef;
print "OPENING $file\n";
open(IN, "$file") || die "painful death! (because there is no $file)";
my ($out);
my $plaintext = <IN>;
open(OUT, ">$file");

my @nums = map(ord, split //, $plaintext);

foreach (@nums) {
print "*";
my $x = @wheel1[0] + @wheel2[0] + @wheel3[0];

if (@ARGV[1] eq "-d") {
$out = $_ + $x;
} else {
$out = $_ - $x;
$out = chr $out;

print OUT $out;

push @wheel1, shift @wheel1;
push @wheel2, shift @wheel2;
print "\b";
Replies are listed 'Best First'.
Re: Ximp
by Zaxo (Archbishop) on Dec 02, 2001 at 12:55 UTC

    This is fun but not too serious crypo. Your wheels have period 16. Give wheel0 9 elements instead of 8 and the period goes to 144=9*16. If the keyword is relatively prime in length, multiply by that length to get the new period. With a long enough plaintext, it's pretty easy to deduce the repetition length and language. From that follows character frequency analysis.

    It's also a concern that addition of random elements in a fixed range _reduces_ randomness.

    After Compline,

Re: Ximp
by sparkyichi (Deacon) on Dec 02, 2001 at 04:57 UTC
    It's enigma all over again. The code is short and to the point, just how Perl should be. Sparky

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: sourcecode [id://128931]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (4)
As of 2021-01-22 04:22 GMT
Find Nodes?
    Voting Booth?