Skip to content

Commit f9261a9

Browse files
committed
[skip travis] Ejemplo de creación de web token
1 parent 48c5356 commit f9261a9

File tree

3 files changed

+26
-0
lines changed

3 files changed

+26
-0
lines changed

ejemplos/jwt/cpanfile

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
requires "Crypt::JWT";

ejemplos/jwt/create-jwt.pl

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/usr/bin/env perl
2+
3+
use strict;
4+
use warnings;
5+
use Crypt::JWT qw(encode_jwt);
6+
7+
use v5.14;
8+
9+
my $name = shift || "estudiante";
10+
11+
say encode_jwt( payload => { user => $name, sub => "IV" },
12+
alg => 'HS256',
13+
key => $ENV{'IV_SECRET'} );
14+

ejemplos/jwt/read-jwt.pl

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/usr/bin/env perl
2+
3+
use Crypt::JWT(decode_jwt);
4+
use strict;
5+
use warnings;
6+
7+
use v5.14;
8+
9+
while ( my $line = <> ) {
10+
say %{decode_jwt( token => $line, key => $ENV{'IV_SECRET'} )};
11+
}

0 commit comments

Comments
 (0)