OATH/Crypt/CBC.pm

filter: Statementstmt 48.5% 17 / 35 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 55.5% 5 / 9 Podpod 100% 3 / 3 totaltotal 53.1% 25 / 47 CC 1 SCAR 3.7
CC
1
Cov
49%
new
2.0
_get_crypt_object
2.0
encrypt
2.0
CRAP 1.4
« OATH/Crypt.pm ↑ Summary OATH/Crypt/Rijndael.pm »
1 package App::OATH::Crypt::CBC;
2 1 our $VERSION = '1.20260324'; # VERSION
3  
4 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use Convert::Base32;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use Crypt::CBC;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use Digest::MD5;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 0 ▶sub new {
Subroutine new: not called CC=1 SCAR=6.9
Pod documented
11 0 my ( $class, $args ) = @_;
12 my $self = {
13 'password' => $args->{'password'},
14 0 'type' => $args->{'type'},
15 };
16 0 bless $self, $class;
17 0 return $self;
18 }
19  
20 0 ▶sub _get_crypt_object {
Subroutine _get_crypt_object: not called CC=1 SCAR=6.9
21 0 my ( $self ) = @_;
22 0 my $password = $self->{'password'};
23  
24 my $crypt = Crypt::CBC->new({
25 'key' => $password,
26 0 'cipher' => $self->{'type'},
27 'salt' => 1,
28 });
29 0 return $crypt;
30 }
31  
32 0 ▶sub encrypt {
Subroutine encrypt: not called CC=1 SCAR=6.9
Pod documented
33 0 my ( $self, $data ) = @_;
34 0 my $worker = $self->_get_crypt_object();
35 0 my $e = $worker->encrypt( $data );
36 0 $e = encode_base32( $e );
37 0 return $e;
38 }
39  
40 0 ▶sub decrypt {
Subroutine decrypt: not called CC=1 SCAR=6.9
Pod documented
41 0 my ( $self, $data ) = @_;
42 0 my $worker = $self->_get_crypt_object();
43 0 my $e = decode_base32( $data );
44 0 my $u = $worker->decrypt($e);
45 0 return $u;
46 }
47  
48 1 1;
49  
50 __END__
« OATH/Crypt.pm ↑ Summary OATH/Crypt/Rijndael.pm »