File Coverage

blib/lib/Eixo/Queue/JobCifrador.pm
Criterion Covered Total %
statement 14 14 100.0
branch n/a
condition n/a
subroutine 5 5 100.0
pod 0 2 0.0
total 19 21 90.4


line stmt bran cond sub pod time code
1             package Eixo::Queue::JobCifrador;
2              
3 4     4   16 use strict;
  4         7  
  4         104  
4 4     4   15 use Eixo::Base::Clase;
  4         8  
  4         30  
5              
6 4     4   2488 use Crypt::JWT qw(encode_jwt decode_jwt);
  4         172674  
  4         932  
7              
8             sub cifrar{
9 1     1 0 26 my ($self, $job, $secreto) = @_;
10              
11 1         3 return encode_jwt(
12              
13             payload=>{
14              
15             sub => $job->to_hash,
16              
17             iat=>time,
18              
19             },
20              
21             key=>$secreto,
22              
23             alg=>"HS256"
24              
25             );
26              
27             }
28              
29             sub descifrar{
30 1     1 0 16 my ($self, $clase_job, $mensaje, $secreto) = @_;
31              
32             return ref($clase_job)->new(
33              
34             %{
35              
36 1         2 decode_jwt(
37              
38             token=>$mensaje,
39              
40             key=>$secreto,
41            
42             alg=>"HS256"
43              
44             )->{sub}
45 1         4 }
46             );
47             }
48              
49             1;