File Coverage

blib/lib/Crypt/OpenBSD/Blowfish.pm
Criterion Covered Total %
statement 17 19 89.4
branch 6 8 75.0
condition n/a
subroutine 6 8 75.0
pod 3 5 60.0
total 32 40 80.0


line stmt bran cond sub pod time code
1             package Crypt::OpenBSD::Blowfish;
2              
3 1     1   13019 use strict;
  1         1  
  1         23  
4 1     1   5 use warnings;
  1         1  
  1         21  
5 1     1   2 use Carp qw( croak );
  1         4  
  1         235  
6              
7             require Exporter;
8              
9             our @ISA = qw(Exporter);
10              
11             # Items to export into callers namespace by default. Note: do not export
12             # names by default without a very good reason. Use EXPORT_OK instead.
13             # Do not simply export all your public functions/methods/constants.
14              
15             # This allows declaration use Crypt::OpenBSD::Blowfish ':all';
16             # If you do not need this, moving things directly into @EXPORT or @EXPORT_OK
17             # will save memory.
18             our %EXPORT_TAGS = ( 'all' => [ qw(
19            
20             ) ] );
21              
22             our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
23              
24             our @EXPORT = qw(
25            
26             );
27              
28             our $VERSION = '0.01';
29              
30             require XSLoader;
31             XSLoader::load('Crypt::OpenBSD::Blowfish', $VERSION);
32              
33             # Preloaded methods go here.
34              
35 0     0 1 0 sub blocksize { 8 }
36 0     0 1 0 sub keysize { 0 }
37 2     2 0 5 sub minkeysize { 4 }
38 2     2 0 4 sub maxkeysize { 56 }
39              
40             sub new {
41 3     3 1 582 my $class = shift;
42 3         3 my $key = shift;
43 3 100       7 if ($key) {
44 2 50       6 croak "Key must be at least " . $class->minkeysize . " octets"
45             if length($key) < $class->minkeysize;
46 2 50       4 $key = substr($key,0,$class->keymaxsize)
47             if length($key) > $class->maxkeysize;
48             }
49 3 100       203 $key ? Crypt::OpenBSD::Blowfish::init_key($key) :
50             Crypt::OpenBSD::Blowfish::init();
51             }
52              
53             1;
54             __END__