Debian Codegraph @

t/rt/27632.t

raw
1 #!/usr/bin/perl
2
3 use strict;
4 use Crypt::Rijndael;
5 use Digest::MD5 qw(md5_hex);
6
7 use Test::More 'no_plan';
8
9 my $class = 'Crypt::Rijndael';
10
11 my $key = 'abcdefghijklmnop';
12
13 my $in_plain = 'a' x 32;
14
15 my $cipher = $class->new( $key, Crypt::Rijndael::MODE_CBC );
16 isa_ok( $cipher, $class );
17
18 $cipher->set_iv('a' x 16);
19
20 # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
21 # encrypt
22 diag( "-" x 50 ) if $ENV{DEBUG};
23
24 my $crypt = $cipher->encrypt( $in_plain );
25
26 diag( "Plain text: [$in_plain]" ) if $ENV{DEBUG};
27 diag( "Crypt text: [$crypt]" ) if $ENV{DEBUG};
28
29 my $digest = md5_hex( $crypt );
30 diag( "MD5 digest of crypt: [$digest]" ) if $ENV{DEBUG};
31
32 # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
33 # decrypt to see if we get back the same thing
34 {
35 diag( "-" x 50 ) if $ENV{DEBUG};
36
37 my $out_plain = $cipher->decrypt( $crypt );
38
39 diag( "Crypt text: [$crypt]" ) if $ENV{DEBUG};
40 diag( "Plain text: [$out_plain]" ) if $ENV{DEBUG};
41
42 is( $out_plain, $in_plain, "Text comes back correctly" );
43 }