File Coverage

blib/lib/Crypt/Skip32/Base64URLSafe.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::Base64URLSafe;
2 1     1   826 use strict;
  1         2  
  1         43  
3 1     1   6 use warnings;
  1         2  
  1         33  
4 1     1   994 use MIME::Base64::URLSafe;
  1         2232  
  1         82  
5             our $VERSION = '0.33';
6 1     1   9 use base 'Crypt::Skip32';
  1         2  
  1         1164  
7              
8             sub encrypt_number_b64_urlsafe {
9 1     1 0 1707 my ( $self, $number ) = @_;
10 1         5 my $plaintext = pack( 'N', $number );
11 1         28 my $ciphertext = $self->encrypt($plaintext);
12 1         237 my $b64 = urlsafe_b64encode($ciphertext);
13 1         19 return $b64;
14             }
15              
16             sub decrypt_number_b64_urlsafe {
17 1     1 0 3 my ( $self, $b64 ) = @_;
18 1         4 my $ciphertext = urlsafe_b64decode($b64);
19 1         42 my $plaintext = $self->decrypt($ciphertext);
20 1         384 my $number = unpack( 'N', $plaintext );
21 1         5 return $number;
22             }
23              
24             1;
25              
26             __END__