| 1 | package App::Netdisco::Util::Token; | ||
| 2 | |||
| 3 | use strict; | ||
| 4 | use warnings; | ||
| 5 | |||
| 6 | use Crypt::URandom (); | ||
| 7 | |||
| 8 | use base 'Exporter'; | ||
| 9 | our @EXPORT = (); | ||
| 10 | our @EXPORT_OK = qw/ random_token /; | ||
| 11 | our %EXPORT_TAGS = (all => \@EXPORT_OK); | ||
| 12 | |||
| 13 | =head1 NAME | ||
| 14 | |||
| 15 | App::Netdisco::Util::Token | ||
| 16 | |||
| 17 | =head1 DESCRIPTION | ||
| 18 | |||
| 19 | Mints session and API authentication secrets. | ||
| 20 | |||
| 21 | There are no default exports, however the C<:all> tag will export all | ||
| 22 | subroutines. | ||
| 23 | |||
| 24 | =head1 EXPORT_OK | ||
| 25 | |||
| 26 | =head2 random_token | ||
| 27 | |||
| 28 | Returns a 64 character lowercase hexadecimal string from L<Crypt::URandom>, | ||
| 29 | a different value on every call. | ||
| 30 | |||
| 31 | =cut | ||
| 32 | |||
| 33 | sub random_token { | ||
| 34 | return unpack 'H*', Crypt::URandom::urandom(32); | ||
| 35 | } | ||
| 36 | |||
| 37 | 1; |