From f778c553ef832660555822e9550864624bc8186b Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Wed, 20 Jul 2011 15:06:06 +0200 Subject: Prepare for configurable key setup cost --- lib/App/Raps2/Password.pm | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'lib/App/Raps2') diff --git a/lib/App/Raps2/Password.pm b/lib/App/Raps2/Password.pm index 129f38d..d80a138 100644 --- a/lib/App/Raps2/Password.pm +++ b/lib/App/Raps2/Password.pm @@ -59,27 +59,29 @@ sub salt { } sub encrypt { - my ( $self, $in, $salt ) = @_; + my ( $self, %opt ) = @_; - $salt //= $self->{salt}; + $opt{salt} //= $self->{salt}; + $opt{cost} //= $self->{cost}; my $eksblowfish - = Crypt::Eksblowfish->new( $self->{cost}, $salt, $self->{passphrase}, ); + = Crypt::Eksblowfish->new( $opt{cost}, $opt{salt}, $self->{passphrase}, ); my $cbc = Crypt::CBC->new( -cipher => $eksblowfish ); - return $cbc->encrypt_hex($in); + return $cbc->encrypt_hex( $opt{data} ); } sub decrypt { - my ( $self, $in, $salt ) = @_; + my ( $self, %opt ) = @_; - $salt //= $self->{salt}; + $opt{cost} //= $self->{cost}; + $opt{salt} //= $self->{salt}; my $eksblowfish - = Crypt::Eksblowfish->new( $self->{cost}, $salt, $self->{passphrase}, ); + = Crypt::Eksblowfish->new( $opt{cost}, $opt{salt}, $self->{passphrase}, ); my $cbc = Crypt::CBC->new( -cipher => $eksblowfish ); - return $cbc->decrypt_hex($in); + return $cbc->decrypt_hex( $opt{data} ); } sub bcrypt { -- cgit v1.2.3