use Crypt::Digest qw(digest_data);
use Errno;
use File::KDBX::Error;
-use File::KDBX::Util qw(:io);
+use File::KDBX::Util qw(:class :io);
use IO::Handle;
use namespace::clean;
-use parent 'File::KDBX::IO';
+extends 'File::KDBX::IO';
our $VERSION = '999.999'; # VERSION
our $ALGORITHM = 'SHA256';
our $BLOCK_SIZE = 1048576; # 1MiB
our $ERROR;
-=method new
-
- $fh = File::KDBX::IO::HashBlock->new(%attributes);
- $fh = File::KDBX::IO::HashBlock->new($fh, %attributes);
-
-Construct a new hash-block stream IO handle.
-
-=cut
-
-sub new {
- my $class = shift;
- my %args = @_ % 2 == 1 ? (fh => shift, @_) : @_;
- my $self = $class->SUPER::new;
- $self->_fh($args{fh}) or throw 'IO handle required';
- $self->algorithm($args{algorithm});
- $self->block_size($args{block_size});
- $self->_buffer;
- return $self;
-}
-
=attr algorithm
Digest algorithm in hash-blocking the stream (default: C<SHA-256>)
my %ATTRS = (
_block_index => 0,
- _buffer => \(my $buf = ''),
+ _buffer => sub { \(my $buf = '') },
_finished => 0,
algorithm => sub { $ALGORITHM },
block_size => sub { $BLOCK_SIZE },
};
}
+=method new
+
+ $fh = File::KDBX::IO::HashBlock->new(%attributes);
+ $fh = File::KDBX::IO::HashBlock->new($fh, %attributes);
+
+Construct a new hash-block stream IO handle.
+
+=cut
+
+sub new {
+ my $class = shift;
+ my %args = @_ % 2 == 1 ? (fh => shift, @_) : @_;
+ my $self = $class->SUPER::new;
+ $self->_fh($args{fh}) or throw 'IO handle required';
+ $self->algorithm($args{algorithm});
+ $self->block_size($args{block_size});
+ $self->_buffer;
+ return $self;
+}
+
sub _FILL {
my ($self, $fh) = @_;