Crypt-OpenSSL3
view release on metacpan or search on metacpan
examples/ciphers.pl view on Meta::CPAN
say length $ciphertext;
say "IV is ", $context->get_param('iv');
my $context2 = Crypt::OpenSSL3::Cipher::Context->new;
$context2->init($cipher, $key, $iv, 0) or die;
my $dec1 = $context2->update($ciphertext) // die;
my $dec2 = $context2->final // die;
my $decoded = $dec1 . $dec2;
say $decoded;
say "Padding was ", $context->get_param('padding');
$context->set_params({ padding => 1 });
say "Padding is now ", $context->get_param('padding');
lib/Crypt/OpenSSL3/Cipher.pm view on Meta::CPAN
my $cipher = Crypt::OpenSSL3::Cipher->fetch('AES-128-GCM');
my $context = Crypt::OpenSSL3::Cipher::Context->new;
$context->init($cipher, $key, $iv, 1);
my $ciphertext = $context->update($plaintext);
$ciphertext .= $context->final;
my $tag = $context->get_aead_tag(16);
my $context2 = Crypt::OpenSSL3::Cipher::Context->new;
$context2->init($cipher, $key, $iv, 0);
my $decoded = $context2->update($ciphertext);
$context2->set_aead_tag($tag);
$decoded .= $context2->final // die "Invalid tag";
=head1 DESCRIPTION
This class holds a symmetric cipher. It's used to create a L<cipher context|Crypt::OpenSSL3::Cipher::Context> that will do the actual encryption/decryption.
=head1 METHODS
=head2 fetch
=head2 get_block_size
t/20-cipher.t view on Meta::CPAN
my $tag = $context->get_aead_tag;
ok length $tag;
my $context2 = Crypt::OpenSSL3::Cipher::Context->new;
$context2->init($cipher, $key, $iv, 0) or die;
my $dec1 = $context2->update($ciphertext) // die;
ok $context2->set_aead_tag($tag);
my $dec2 = $context2->final // die;
my $decoded = $dec1 . $dec2;
is $decoded, $plain, 'Decoded text matches original plaintext';
done_testing;
( run in 0.562 second using v1.01-cache-2.11-cpan-9383018d099 )