diff options
author | Daniel Friesel <derf@finalrewind.org> | 2011-07-20 15:06:06 +0200 |
---|---|---|
committer | Daniel Friesel <derf@finalrewind.org> | 2011-07-20 15:06:06 +0200 |
commit | f778c553ef832660555822e9550864624bc8186b (patch) | |
tree | 596b30c74d427066c1ef2b06fb1834f1bec2fb60 /lib/App/Raps2 | |
parent | 253e74d49ac3ec7f064aa0fc18eafc3b09cde9a4 (diff) |
Prepare for configurable key setup cost
Diffstat (limited to 'lib/App/Raps2')
-rw-r--r-- | lib/App/Raps2/Password.pm | 18 |
1 files changed, 10 insertions, 8 deletions
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 { |