1
0
mirror of https://github.com/hashcat/hashcat.git synced 2024-12-23 15:18:16 +00:00
hashcat/tools/test_modules/m20600.pm

55 lines
955 B
Perl
Raw Normal View History

#!/usr/bin/env perl
##
## Author......: See docs/credits.txt
## License.....: MIT
##
use strict;
use warnings;
2022-01-30 09:35:51 +00:00
use Digest::SHA qw (sha256);
use MIME::Base64 qw (encode_base64);
sub module_constraints { [[0, 256], [0, 16], [-1, -1], [-1, -1], [-1, -1]] }
sub module_generate_hash
{
my ($word, $salt, $iter) = @_;
return unless defined $word;
return unless defined $salt;
$iter //= 1000;
2020-06-13 09:19:00 +00:00
my $digest = sha256 ($salt . $word);
2020-06-13 09:19:00 +00:00
for (my $i = 1; $i < $iter; $i++)
{
$digest = sha256 ($digest);
}
2020-06-13 09:19:00 +00:00
chomp ($digest = encode_base64 ($digest));
my $hash = sprintf ("otm_sha256:%d:%s:%s", $iter, $salt, $digest);
return $hash;
}
sub module_verify_hash
{
my $line = shift;
my ($sig, $iter, $salt, $hash, $word) = split (':', $line);
return unless defined $iter;
return unless defined $salt;
return unless defined $word;
2021-06-21 15:47:22 +00:00
my $new_hash = module_generate_hash ($word, $salt, $iter);
return ($new_hash, $word);
}
1;