1#!/usr/bin/env perl 2 3## 4## Author......: See docs/credits.txt 5## License.....: MIT 6## 7 8use strict; 9use warnings; 10 11use Crypt::DES; 12 13sub module_constraints { [[8, 8], [16, 16], [-1, -1], [-1, -1], [-1, -1]] } 14 15sub module_generate_hash 16{ 17 my $word = shift; 18 my $salt = shift; 19 20 my $cipher = new Crypt::DES ($word); 21 22 my $pt_bin = pack ("H*", $salt); 23 24 my $ct_bin = $cipher->encrypt ($pt_bin); 25 26 my $hash = sprintf ("%s:%s", unpack ("H*", $ct_bin), $salt); 27 28 return $hash; 29} 30 31sub module_verify_hash 32{ 33 my $line = shift; 34 35 my ($hash, $salt, $word) = split (':', $line); 36 37 return unless defined $hash; 38 return unless defined $salt; 39 return unless defined $word; 40 41 my $word_packed = pack_if_HEX_notation ($word); 42 43 my $new_hash = module_generate_hash ($word_packed, $salt); 44 45 return ($new_hash, $word); 46} 47 481; 49