On 06.05.21 14:15, Thomas Lamprecht wrote: > sub check_file_hash > my ($algorithm, $expected, $file) = @_; > > my $algorithm_map = { > 'sha256' => sub { Digest::SHA->new(512) },
argh, naturally above should use 256, but you get the idea ;-) > 'sha512' => sub { Digest::SHA->new(512) }, > # etc... > }; > > my $digester = $algorithm_map->{$algorithm}->() or die "unknown algorithm > '$algorithm'\n"; > > open(my $fh, '<', $filename) or die "cannot open file '$file': $!\n"; > > my $got = $digester->addfile($fh)->hexdigest; > close($fh); > > return lc($digest) eq lc($expected); > } _______________________________________________ pve-devel mailing list pve-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel