line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Crypt::Blowfish::Mod; |
2
|
|
|
|
|
|
|
our $VERSION = '0.05'; |
3
|
|
|
|
|
|
|
|
4
|
1
|
|
|
1
|
|
770
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
28
|
|
5
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
22
|
|
6
|
1
|
|
|
1
|
|
5
|
use Carp; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
54
|
|
7
|
1
|
|
|
1
|
|
470
|
use MIME::Base64; |
|
1
|
|
|
|
|
658
|
|
|
1
|
|
|
|
|
59
|
|
8
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
|
7
|
use vars qw/$VERSION @ISA/; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
481
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
require DynaLoader; |
12
|
|
|
|
|
|
|
@ISA = qw/DynaLoader/; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
bootstrap Crypt::Blowfish::Mod $VERSION; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub new { |
17
|
10
|
|
|
10
|
1
|
25241
|
my $class = shift; |
18
|
10
|
100
|
|
|
|
38
|
my %p = @_ == 1 ? ( key=>shift ) : ( @_ ); |
19
|
|
|
|
|
|
|
|
20
|
10
|
50
|
66
|
|
|
52
|
confess "Missing 'key' parameter to $class->new()" unless( $p{key} || $p{key_raw} ); |
21
|
|
|
|
|
|
|
|
22
|
10
|
|
33
|
|
|
43
|
my $endianness = $p{endianness} || $class->_detect_endianness; |
23
|
10
|
|
66
|
|
|
32
|
my $key = $p{key_raw} || MIME::Base64::decode_base64( $p{key} ); |
24
|
10
|
|
|
|
|
69
|
return bless( { key => $key, endianness=>$endianness }, $class ); |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub _detect_endianness { |
28
|
10
|
50
|
|
10
|
|
71
|
return 10002000 == unpack("h*", pack("s2", 1, 2)) ? 'little' : 'big'; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub _is_big_endian { |
32
|
116
|
|
|
116
|
|
223
|
my $self = shift; |
33
|
116
|
50
|
|
|
|
4996484
|
return $self->{endianness} eq 'little' ? 0 : 1; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub encrypt_raw { |
37
|
2
|
|
|
2
|
1
|
8
|
my ($self, $str ) = @_; |
38
|
2
|
|
|
|
|
8
|
return MIME::Base64::decode_base64($self->encrypt($str)); |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub decrypt_raw { |
42
|
2
|
|
|
2
|
1
|
14
|
my ($self, $str ) = @_; |
43
|
2
|
|
|
|
|
9
|
$self->decrypt( MIME::Base64::encode_base64($str, '') ); |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub encrypt { |
47
|
57
|
|
|
57
|
1
|
62330
|
my ($self, $str ) = @_; |
48
|
57
|
|
|
|
|
249
|
return Crypt::Blowfish::Mod::b_encrypt( $self->{key}, $str, $self->_is_big_endian, 0 ) |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub encrypt_legacy { |
52
|
2
|
|
|
2
|
1
|
6
|
my ($self, $str ) = @_; |
53
|
2
|
|
|
|
|
7
|
return Crypt::Blowfish::Mod::b_encrypt( $self->{key}, $str, $self->_is_big_endian, 1 ) |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub decrypt { |
57
|
57
|
|
|
57
|
1
|
1188
|
my ($self, $str ) = @_; |
58
|
57
|
|
|
|
|
190
|
return Crypt::Blowfish::Mod::b_decrypt( $self->{key}, $str, $self->_is_big_endian ); |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
1; |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
__END__ |