1#! /usr/local/bin/perl -w 2 3use strict; 4use IO::File; 5 6eval 'use Crypt::CBC 1.22'; 7 8print "1..5\n"; 9if ($@) { 10 print "ok # skipped in absence of Crypt::CBC 1.22 or higher\n" 11 x 5; 12 exit 0; 13} else { 14 print "ok 1\n"; 15} 16 17my @algos = qw (Twofish_PP 18 Twofish_PP::Key16 Twofish_PP::Key24 Twofish_PP::Key32); 19 20for my $i (2 .. 5) { 21 my $copying; 22 23 my $fh; 24 my $here = $0; 25 $here =~ m@^(.*)[\\/].*$@; 26 $here = $1 || '.'; 27 28 local $/; 29 $fh = IO::File->new ("<$here/../Artistic") 30 or die; 31 32 $copying = <$fh>; 33 die unless defined $copying; 34 $fh->close; 35 36 eval { 37 my $key = 'Not very secret'; 38 my $cipher; 39 40 $cipher = Crypt::CBC->new ($key, shift @algos) 41 or die; 42 43 my $result = $cipher->decrypt ($cipher->encrypt ($copying)) 44 or die; 45 46 $result eq $copying or die; 47 }; 48 print $@ ? "not ok $i\n" : "ok $i\n"; 49} 50 51