DTOne-Crypt
view release on metacpan or search on metacpan
lib/DTOne/Crypt.pm view on Meta::CPAN
undef,
$ciphertext,
$tag
);
}
sub _is_v2_format {
my $encrypted = shift or croak "encrypted data required";
return substr($encrypted, 0, 1) eq '$';
}
1;
__END__
=encoding utf-8
=head1 NAME
DTOne::Crypt - Cryptographic Toolkit
=head1 SYNOPSIS
use DTOne::Crypt qw(encrypt_aes256gcm decrypt_aes256gcm);
my $encrypted = encrypt_aes256gcm($plaintext, $master_key);
my $decrypted = decrypt_aes256gcm($encrypted, $master_key);
=head1 DESCRIPTION
L<DTOne::Crypt> provides a cryptographic toolkit intended to abstract
complexities in data interchange.
=head1 FUNCTIONS
L<DTone::Crypt> implements the following functions, which can be imported
individually:
=head2 encrypt_aes256gcm
my $encrypted = encrypt_aes256gcm($plaintext, $master_key);
Encrypt plaintext value using AES-256 GCM to a base64 encoded string containing
the initialization vector (IV), ciphertext, and tag.
=head2 decrypt_aes256gcm
my $decrypted = decrypt_aes256gcm($encrypted, $master_key);
Decrypt a composite base64 encoded string containing the IV, ciphertext, and tag
back to its original plaintext value.
=head1 CAVEATS
=head2 Key Length
Master key is expected to be exactly 256 bits in length, encoded in base64.
=head2 Performance
Random byte generation on Linux might run slow over time unless L<haveged(8)>
is running. In this scenario, the streaming facility of AES-GCM will be more
memory efficient.
=head1 AUTHOR
Arnold Tan Casis E<lt>atancasis@cpan.orgE<gt>
=head1 ACKNOWLEDGMENTS
L<Pierre Gaulon|https://github.com/pgaulon> and L<Jose Nidhin|https://github.com/josnidhin>
for their valued inputs in interpreting numerous security recommendations and in
designing the data interchange protocol used in this module.
L<Sherwin Daganato|https://metacpan.org/author/SHERWIN> for the note on random
byte generation and caveats to performance on Linux systems.
L<Pierre Vigier|https://metacpan.org/author/PVIGIER> for the note on cross-language
compatibility with libraries in Go and Java.
=head1 COPYRIGHT
Copyright 2020- Arnold Tan Casis
=head1 LICENSE
This library is free software; you can redistribute it and/or modify it under
the same terms as Perl itself.
=head1 SEE ALSO
See L<CryptX> for an excellent generic cryptographic toolkit.
=cut
( run in 4.144 seconds using v1.01-cache-2.11-cpan-140bd7fdf52 )