perl-openssl / perl-Crypt-OpenSSL-AES

https://metacpan.org/pod/Crypt::OpenSSL::AES
Other
2 stars 2 forks source link
aes cryptography encryption perl

NAME

Crypt::OpenSSL::AES - A Perl wrapper around OpenSSL's AES library

SYNOPSIS

 use Crypt::OpenSSL::AES;

 my $cipher = Crypt::OpenSSL::AES->new($key);

 or

 # Pick better keys and iv...
 my $key = pack("H*", substr(sha512_256_hex(rand(1000)), 0, ($ks/4)));
 my $iv  = pack("H*", substr(sha512_256_hex(rand(1000)), 0, 32));
 my $cipher = Crypt::OpenSSL::AES->new(
                                        $key,
                                        {
                                            cipher => 'AES-256-CBC',
                                            iv      => $iv, (16-bytes for supported ciphers)
                                            padding => 1, (0 - no padding, 1 - padding)
                                        }
                                    );

 $encrypted = $cipher->encrypt($plaintext);
 $decrypted = $cipher->decrypt($encrypted);

DESCRIPTION

This module implements a wrapper around OpenSSL. Specifically, it wraps the methods related to the US Government's Advanced Encryption Standard (the Rijndael algorithm). The original version supports only AES ECB (electronic codebook mode encryption).

This module is compatible with Crypt::CBC (and likely other modules that utilize a block cipher to make a stream cipher).

This module is an alternative to the implementation provided by Crypt::Rijndael which implements AES itself. In contrast, this module is simply a wrapper around the OpenSSL library.

As of version 0.09 additional AES ciphers are supported. Those are:

USE WITH CRYPT::CBC

As padding is now supported for the CBC cipher, Crypt::CBC is no longer required but supported for backward compatibility.

    use Crypt::CBC;

    my $plaintext = "This is a test!!";
    my $password = "qwerty123";
    my $cipher = Crypt::CBC->new(
            -key    => $password,
            -cipher => "Crypt::OpenSSL::AES",
            -pbkdf  => 'pbkdf2',
    );

    my $encrypted = $cipher->encrypt($plaintext);
    my $decrypted = $cipher->decrypt($encrypted);

SEE ALSO

Crypt::CBC

http://www.openssl.org/

http://en.wikipedia.org/wiki/Advanced\_Encryption\_Standard

http://www.csrc.nist.gov/encryption/aes/

BUGS

Need more (and better) test cases.

AUTHOR

Tolga Tarhan, <cpan at ttar dot org>

The US Government's Advanced Encryption Standard is the Rijndael Algorithm and was developed by Vincent Rijmen and Joan Daemen.

COPYRIGHT AND LICENSE

Copyright (C) 2006 - 2024 DelTel, Inc.

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.5 or, at your option, any later version of Perl 5 you may have available.