http://www.perlmonks.org?node_id=1059990


in reply to Decent crypto library?

Replies are listed 'Best First'.
Re^2: Decent crypto library?
by vsespb (Chaplain) on Oct 28, 2013 at 14:46 UTC
    Thank you.

    Crypt::Cipher::AES - there was a typo in my post. I already tried this one. And it's as slow as others in Crypt::CBC mode

    Crypt::MCrypt - Cannot get it working with RIJNDAEL-256 (I tried also "aes", "aes256") - getting segfaults

        Thank you. 5.5 times slower. Not so bad.
        use strict; use warnings; use Digest::MD5 qw/md5_hex/; use Time::HiRes qw/tv_interval gettimeofday/; use Crypt::Mode::CBC; my $key = "\241(_E\203\223\337\322\317\214\24'\352\231\352\177W\\\6^\3 +21a\3\6:-qQ\r\225&\264"; my $IV = "<C\202\305\377\305\205\24\211\321\257\372z\363\333\357"; my $IV_hex = unpack('H*', $IV); my $key_hex = unpack('H*', $key); my $m = Crypt::Mode::CBC->new('AES'); my $s = "x" x 100_000_000; my $ciphertext = $m->encrypt($s, $key, $IV); my ($t0, $t1); $t0 = [gettimeofday]; my $ss = $m->decrypt($ciphertext, $key, $IV); $t1 = [gettimeofday]; die unless $ss eq $s; print "decrypt Crypt::Mode::CBC\t"; print tv_interval $t0, $t1; print "\n"; open my $f, ">", "/tmp/enctest"; binmode $f; print $f $ciphertext; close $f; my $sdata_md5 = md5_hex($s); $t0 = [gettimeofday]; unlink '/tmp/enctest.out'; system 'openssl', 'enc', '-aes-256-cbc', '-d', '-in', '/tmp/enctest', +'-out', '/tmp/enctest.out', '-K', $key_hex, '-iv', $IV_hex; $t1 = [gettimeofday]; print "decrypt OPENSSL\t"; print tv_interval $t0, $t1; print "\n"; die unless `md5sum /tmp/enctest.out` =~ /$sdata_md5/; __END__ decrypt Crypt::Mode::CBC 0.91427 decrypt OPENSSL 0.149651