File Coverage

blib/lib/Crypt/Skip32/Base32Crockford.pm
Criterion Covered Total %
statement 22 22 100.0
branch n/a
condition n/a
subroutine 6 6 100.0
pod 0 2 0.0
total 28 30 93.3


line stmt bran cond sub pod time code
1             package Crypt::Skip32::Base32Crockford;
2 1     1   660 use strict;
  1         1  
  1         41  
3 1     1   6 use warnings;
  1         1  
  1         35  
4 1     1   849 use Encode::Base32::Crockford qw(base32_encode base32_decode);
  1         1114  
  1         76  
5             our $VERSION = '0.33';
6 1     1   5 use base 'Crypt::Skip32';
  1         2  
  1         709  
7              
8             sub encrypt_number_b32_crockford {
9 1     1 0 936 my ( $self, $number ) = @_;
10 1         3 my $plaintext = pack( 'N', $number );
11 1         21 my $ciphertext = $self->encrypt($plaintext);
12 1         176 my $b64 = base32_encode( unpack 'N', $ciphertext );
13 1         28 return $b64;
14             }
15              
16             sub decrypt_number_b32_crockford {
17 1     1 0 3 my ( $self, $b64 ) = @_;
18 1         3 my $ciphertext = base32_decode($b64);
19 1         58 my $plaintext = $self->decrypt( pack 'N', $ciphertext );
20 1         204 my $number = unpack( 'N', $plaintext );
21 1         4 return $number;
22             }
23              
24             1;
25              
26             __END__