Encryption and decryption in Perl can be accomplished using cryptography modules like `Crypt::CBC` and `Crypt::OpenSSL::AES`. Below, you'll find an example that demonstrates how to encrypt and decrypt data using these modules.
#!/usr/bin/perl
use strict;
use warnings;
use Crypt::CBC;
use MIME::Base64;
# Create a new cipher
my $key = 'This is a key123'; # Key must be 16 characters for AES-128
my $cipher = Crypt::CBC->new(-key => $key, -cipher => 'Crypt::OpenSSL::AES');
# Data to encrypt
my $data = "Hello, World!";
# Encrypt the data
my $encrypted = $cipher->encrypt($data);
my $encoded_encrypted = encode_base64($encrypted);
print "Encrypted and Base64 Encoded: $encoded_encrypted\n";
# Decrypt the data
my $decrypted = $cipher->decrypt(decode_base64($encoded_encrypted));
print "Decrypted: $decrypted\n";
How do I avoid rehashing overhead with std::set in multithreaded code?
How do I find elements with custom comparators with std::set for embedded targets?
How do I erase elements while iterating with std::set for embedded targets?
How do I provide stable iteration order with std::unordered_map for large datasets?
How do I reserve capacity ahead of time with std::unordered_map for large datasets?
How do I erase elements while iterating with std::unordered_map in multithreaded code?
How do I provide stable iteration order with std::map for embedded targets?
How do I provide stable iteration order with std::map in multithreaded code?
How do I avoid rehashing overhead with std::map in performance-sensitive code?
How do I merge two containers efficiently with std::map for embedded targets?