1
0
mirror of https://github.com/hashcat/hashcat.git synced 2024-11-14 03:39:09 +00:00
hashcat/tools/test_modules/m24900.pm

57 lines
1.0 KiB
Perl

#!/usr/bin/env perl
##
## Author......: See docs/credits.txt
## License.....: MIT
##
use strict;
use warnings;
use MIME::Base64 qw (encode_base64 decode_base64);
use Digest::MD5 qw (md5);
sub module_constraints { [[-1, -1], [-1, -1], [0, 55], [-1, -1], [-1, -1]] }
my $itoa62 = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
sub module_generate_hash
{
my $word = shift;
my $digest = md5 ($word);
my @chksum;
for (my $i = 0, my $j = 0; $i < 16; $i += 2, $j += 1)
{
$chksum[$j] = (ord (substr ($digest, $i + 0, 1)) + ord (substr ($digest, $i + 1, 1))) % 62;
$chksum[$j] = substr ($itoa62, $chksum[$j], 1);
}
my $res = join "", @chksum;
my $hash = sprintf ("%s", $res);
return $hash;
}
sub module_verify_hash
{
my $line = shift;
my ($hash, $word) = split (':', $line);
return unless defined $hash;
return unless defined $word;
my $word_packed = pack_if_HEX_notation ($word);
my $new_hash = module_generate_hash ($word_packed);
return ($new_hash, $word);
}
1;