Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re^4: Decent crypto library?

by vsespb (Hermit)
on Oct 28, 2013 at 17:55 UTC ( #1060023=note: print w/ replies, xml ) Need Help??


in reply to Re^3: Decent crypto library?
in thread Decent crypto library?

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


Comment on Re^4: Decent crypto library?
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1060023]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (9)
As of 2014-11-27 08:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My preferred Perl binaries come from:














    Results (182 votes), past polls