line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Crypt::Blowfish::Mod; |
2
|
|
|
|
|
|
|
our $VERSION = '0.04'; |
3
|
|
|
|
|
|
|
|
4
|
1
|
|
|
1
|
|
856
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
70
|
|
5
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
38
|
|
6
|
1
|
|
|
1
|
|
14
|
use Carp; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
79
|
|
7
|
1
|
|
|
1
|
|
1635
|
use MIME::Base64; |
|
1
|
|
|
|
|
916
|
|
|
1
|
|
|
|
|
77
|
|
8
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
|
6
|
use vars qw/$VERSION @ISA/; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
460
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
require DynaLoader; |
12
|
|
|
|
|
|
|
@ISA = qw/DynaLoader/; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
bootstrap Crypt::Blowfish::Mod $VERSION; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub new { |
17
|
6
|
|
|
6
|
1
|
3424
|
my $class = shift; |
18
|
6
|
100
|
|
|
|
32
|
my %p = @_ == 1 ? ( key=>shift ) : ( @_ ); |
19
|
|
|
|
|
|
|
|
20
|
6
|
50
|
66
|
|
|
36
|
confess "Missing 'key' parameter to $class->new()" unless( $p{key} || $p{key_raw} ); |
21
|
|
|
|
|
|
|
|
22
|
6
|
|
33
|
|
|
25
|
my $endianness = $p{endianness} || $class->_detect_endianness; |
23
|
6
|
|
66
|
|
|
35
|
my $key = $p{key_raw} || MIME::Base64::decode_base64( $p{key} ); |
24
|
6
|
|
|
|
|
58
|
return bless( { key => $key, endianness=>$endianness }, $class ); |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub _detect_endianness { |
28
|
6
|
50
|
|
6
|
|
43
|
return 10002000 == unpack("h*", pack("s2", 1, 2)) ? 'little' : 'big'; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub _is_big_endian { |
32
|
108
|
|
|
108
|
|
196
|
my $self = shift; |
33
|
108
|
50
|
|
|
|
7215228
|
return $self->{endianness} eq 'little' ? 0 : 1; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub encrypt_raw { |
37
|
1
|
|
|
1
|
1
|
5
|
my ($self, $str ) = @_; |
38
|
1
|
|
|
|
|
5
|
return MIME::Base64::decode_base64($self->encrypt($str)); |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub decrypt_raw { |
42
|
1
|
|
|
1
|
1
|
6
|
my ($self, $str ) = @_; |
43
|
1
|
|
|
|
|
8
|
$self->decrypt( MIME::Base64::encode_base64($str, '') ); |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub encrypt { |
47
|
55
|
|
|
55
|
1
|
75824
|
my ($self, $str ) = @_; |
48
|
55
|
|
|
|
|
349
|
return Crypt::Blowfish::Mod::b_encrypt( $self->{key}, $str, $self->_is_big_endian ) |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub decrypt { |
52
|
53
|
|
|
53
|
1
|
1105
|
my ($self, $str ) = @_; |
53
|
53
|
|
|
|
|
338
|
return Crypt::Blowfish::Mod::b_decrypt( $self->{key}, $str, $self->_is_big_endian ); |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
1; |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
__END__ |