1#!/usr/bin/env perl 2 3## 4## Author......: See docs/credits.txt 5## License.....: MIT 6## 7 8use strict; 9use warnings; 10 11use Digest::MD5 qw (md5_hex); 12use Digest::MD5 qw (md5); 13 14sub module_constraints { [[0, 256], [-1, -1], [0, 55], [-1, -1], [-1, -1]] } 15 16sub module_generate_hash 17{ 18 my $word = shift; 19 20 my $digest1 = md5 ($word); 21 22 my $digest1_sub = substr ($digest1, 0, 5); 23 24 my $digest2 = md5 ($digest1_sub); 25 26 my $digest2_sub = substr ($digest2, 0, 5); 27 28 my $hash = sprintf ("%s", unpack ("H*", $digest2_sub)); 29 30 return $hash; 31} 32 33sub module_verify_hash 34{ 35 my $line = shift; 36 37 my ($hash, $word) = split (':', $line); 38 39 return unless defined $hash; 40 return unless defined $word; 41 42 my $word_packed = pack_if_HEX_notation ($word); 43 44 my $new_hash = module_generate_hash ($word_packed); 45 46 return ($new_hash, $word); 47} 48 491; 50