1
# tests the fh_encrypt() method
2
# this will fail if the state array is not reinitialized ... oops!
3
use Crypt::CipherSaber;
6
my $crypt_in = File::Spec->catfile('t', 'smiles.cs1');
7
my $crypt_out = File::Spec->catfile('t', 'outsmiles.cs1');
8
my $img_in = File::Spec->catfile('t', 'smiles.png');
9
my $img_out = File::Spec->catfile('t', 'outsmiles.png');
13
open(IN, $crypt_in) or die "Can't get IV!\n";
15
my $iv = unpack("a10", <IN>);
18
my $cs = Crypt::CipherSaber->new('sdrawkcabsihtdaeR');
19
open(IN, $img_in) or die "Can't open input file!\n";
20
open(OUT, '>'. $crypt_out) or die "Can't open output file!\n";
24
if ($cs->fh_crypt(\*IN, \*OUT, $iv)) {
30
open(ENCRYPTED, $crypt_out) or die "Can't open encrypted file!\n";
31
open(FIXED, $crypt_in) or die "Can't open fixed file!\n";
39
for my $char (split(//, $_)) {
40
next if (substr($fixed, $pos++, 1) eq $char);
52
open(IN, $crypt_in) or die "Can't open input file 2!\n";
53
open(OUT, '>' . $img_out) or die "Can't open output file 2!\n";
57
if ($cs->fh_crypt(\*IN, \*OUT)) {
66
open(ENCRYPTED, $img_out) or die "Can't open encrypted file!\n";
67
open(FIXED, $img_in) or die "Can't open fixed file!\n";
75
for my $char (split(//, $_)) {
76
next if (substr($fixed, $pos++, 1) eq $char);
78
print STDERR "Error at line $.\n";