Skip to content

Commit

Permalink
initialize prng late
Browse files Browse the repository at this point in the history
  • Loading branch information
haarg committed Dec 28, 2024
1 parent 8d2d8b5 commit 4bf24d9
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions lib/MetaCPAN/CSP.pm
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,16 @@ has _directives => (
},
);

my $rng = Math::Random::ISAAC::XS->new( unpack( "C*", urandom_ub(16) ) );

sub _nonce_generator {
sprintf( '%x', $rng->irand );
sub _build_nonce_generator {
my $rng = Math::Random::ISAAC::XS->new( unpack( "C*", urandom_ub(16) ) );
sub {
sprintf( '%x', $rng->irand );
};
}

has nonce_gen => (
is => 'ro',
default => sub { \&_nonce_generator },
is => 'lazy',
builder => 1,
);

has nonce => (
Expand Down

0 comments on commit 4bf24d9

Please sign in to comment.