SPVM-HTTP-Tiny

 view release on metacpan or  search on metacpan

lib/SPVM/HTTP/Tiny/Util.spvm  view on Meta::CPAN

  croak 'CryptX 0.080+ required for encrypted cookie support' unless CRYPTX;

  my $dk = $ENCRYPTION{$key}{$salt} ||= Crypt::KeyDerivation::pbkdf2($key, $salt);
  my $iv = Crypt::PRNG::random_bytes(12);
  my ($ct, $tag) = Crypt::AuthEnc::ChaCha20Poly1305::chacha20poly1305_encrypt_authenticate($dk, $iv, '', $value);

  return join '-', Crypt::Misc::encode_b64($ct), Crypt::Misc::encode_b64($iv), Crypt::Misc::encode_b64($tag);
}

sub extract_usage {
  my $file = @_ ? "$_[0]" : (caller)[1];

  open my $handle, '>', \my $output;
  pod2usage -exitval => 'noexit', -input => $file, -output => $handle;
  $output =~ s/^.*\n|\n$//;
  $output =~ s/\n$//;

  return unindent($output);
}

sub generate_secret {



( run in 0.342 second using v1.01-cache-2.11-cpan-a3c8064c92c )