Skip to content

Commit 81a8f77

Browse files
committed
Add test for github issue #7
1 parent 40d0e13 commit 81a8f77

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

t/github-issue7.t

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
use strict;
2+
use warnings;
3+
use Test::More;
4+
use Crypt::CBC;
5+
6+
eval "use Crypt::Blowfish()";
7+
if ($@) {
8+
print "1..0 # Skipped: Crypt::Blowfish not installed\n";
9+
exit;
10+
}
11+
12+
# small script for Blowfish encryption and decryption
13+
14+
# The key for the blowfish encoding/decoding below
15+
my $privateString = '123456789012345678901234567890123456789012';
16+
17+
my $teststring = "Testtext";
18+
19+
my $key = pack('H*', $privateString);
20+
21+
my $params = {
22+
'key' => $key,
23+
'cipher' => 'Blowfish',
24+
'header' => 'randomiv',
25+
'nodeprecate' => 1
26+
};
27+
28+
my $cipher = Crypt::CBC->new($params);
29+
my $encoded = $cipher->encrypt_hex($teststring);
30+
31+
my $decoded = $cipher->decrypt_hex($encoded);
32+
33+
ok($teststring eq $decoded, "Properly decoded Blowfish with header => randomiv");
34+
35+
done_testing();

0 commit comments

Comments
 (0)