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

In reply to Re^4: Decent crypto library? by vsespb
in thread Decent crypto library? by vsespb

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.