| 1 | package Net::PT::Test; | ||
| 2 | |||
| 3 | 1 | ▶ | use 5.006; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | 1 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | 1 | ▶ | use warnings FATAL => 'all'; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 6 | |||
| 7 | =head1 NAME | ||
| 8 | |||
| 9 | Net::PT::Test - The great new Net::PT! | ||
| 10 | |||
| 11 | =head1 VERSION | ||
| 12 | |||
| 13 | Version 0.01 | ||
| 14 | |||
| 15 | |||
| 16 | |||
| 17 | |||
| 18 | =head1 ACKNOWLEDGEMENTS | ||
| 19 | |||
| 20 | |||
| 21 | =head1 LICENSE AND COPYRIGHT | ||
| 22 | |||
| 23 | Copyright 2013 Paul Taylor. | ||
| 24 | |||
| 25 | This program is released under the following license: BSD | ||
| 26 | |||
| 27 | |||
| 28 | =cut | ||
| 29 | |||
| 30 | our $VERSION = '0.01'; | ||
| 31 | |||
| 32 | 1 | ▶ | use 5.006; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 33 | 1 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 34 | 1 | ▶ | use warnings FATAL => 'all'; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 35 | |||
| 36 | 1 | ▶ | use Time::HiRes qw(gettimeofday); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 37 | 1 | ▶ | use Math::Random::Secure qw(irand); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 38 | 1 | ▶ | use JSON; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 39 | 1 | ▶ | use MIME::Base64 qw(decode_base64 decode_base64url encode_base64url); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 40 | 1 | ▶ | use Crypt::Mac::HMAC qw( hmac_b64u ); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 41 | 1 | ▶ | use Carp; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 42 | 1 | ▶ | use URI::Encode qw(uri_encode); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 43 | 1 | ▶ | use Mozilla::CA; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 44 | |||
| 45 | 0 | ▶ | use Data::Printer; |
|
Subroutine
BEGIN: called CC=1 SCAR=2.6
| |||
| 46 | |||
| 47 | sub test { | ||
| 48 | my ($class, $s) = @_; | ||
| 49 | |||
| 50 | print "Net::PT::Test - test(${class}, ${s})\n"; | ||
| 51 | |||
| 52 | my $map = { | ||
| 53 | class => $class, | ||
| 54 | msg => $s | ||
| 55 | }; | ||
| 56 | print "Net::PT::Test - map = \n"; | ||
| 57 | p $map; | ||
| 58 | |||
| 59 | |||
| 60 | my $json = encode_json $map; | ||
| 61 | print "Net:PT - json = \n"; | ||
| 62 | p $json; | ||
| 63 | |||
| 64 | my $b64 = encode_base64url $json; | ||
| 65 | print "Net::PT::Test - base64 url = \n"; | ||
| 66 | p $b64; | ||
| 67 | |||
| 68 | my $key = "monkey"; | ||
| 69 | my $hmac = hmac_b64u('SHA256', $key, $b64); | ||
| 70 | print "Net::PT::Test - hmac = \n"; | ||
| 71 | p $hmac; | ||
| 72 | |||
| 73 | my $json2 = decode_base64url $b64; | ||
| 74 | print "Net:PT - json2 = \n"; | ||
| 75 | p $json2; | ||
| 76 | |||
| 77 | my $map2 = decode_json $json2; | ||
| 78 | print "Net:PT - map2 = \n"; | ||
| 79 | p $map2; | ||
| 80 | |||
| 81 | |||
| 82 | |||
| 83 | } | ||
| 84 | |||
| 85 | |||
| 86 | |||
| 87 | |||
| 88 | 1; | ||
| 89 | |||