1
0
mirror of https://github.com/hashcat/hashcat.git synced 2024-11-14 03:39:09 +00:00
hashcat/tools/test_modules/m16400.pm
mhasbini e085177e58 Add unit tests for multiple modules:
15500, 15600, 15700, 16000, 16100, 16200, 16300, 16400, 16500, 16600 & 16700
2019-02-15 21:48:09 +02:00

56 lines
1.0 KiB
Perl

#!/usr/bin/env perl
##
## Author......: See docs/credits.txt
## License.....: MIT
##
use strict;
use warnings;
use Digest::Perl::MD5;
sub module_constraints { [[0, 64], [-1, -1], [0, 55], [-1, -1], [-1, -1]] }
sub module_generate_hash
{
my $word = shift;
my $md5 = Digest::Perl::MD5->new;
my $length = length ($word);
$md5->{_data} = $word ^ ("\x5c" x $length);
$md5->{_data} .= "\x5c" x (64 - $length);
$md5->add();
my $digest = unpack ("H*", pack ('V4', @{$md5->{_state}}));
my $hash = sprintf ("{CRAM-MD5}%s00000000000000000000000000000000", $digest);
return $hash;
}
sub module_verify_hash
{
my $line = shift;
my ($digest, $word) = split (':', $line);
return unless defined $digest;
return unless defined $word;
my $signature = substr ($digest, 0, 10);
return unless ($signature eq "{CRAM-MD5}");
my $hash = substr ($digest, 10);
my $word_packed = pack_if_HEX_notation ($word);
my $new_hash = module_generate_hash ($word_packed);
return ($new_hash, $word);
}
1;