Perl module Crypt::SmbHash released
Toomas Soome
tsoome at ut.ee
Tue Oct 2 01:00:18 GMT 2001
Benjamin Kuit wrote:
>
> I've released my perl port of lib/md4.c and libsmb/smbdes.c to CPAN
> as a single module Crypt::SmbHash, so Samba administrators can now
> generate LM/NT password hashes for smbpasswd style entries within
> perl scripts without calling external programs.
>
> It's entirely in perl, so its a bit slow, but the upside is that it's
> portable.
>
> You can speed it up by having Digest::MD4 installed as well.
>
> Figured it would be useful to others.
>
> We now return you to your regular scheduled programming.
>
hm.
[107] root at madli:build/Crypt-SmbHash-0.01> make test
cp SmbHash.pm blib/lib/Crypt/SmbHash.pm
PERL_DL_NONLAZY=1 /bin/perl -Iblib/arch -Iblib/lib
-I/usr/local/lib/perl5/5.6.1/sun4-solaris -I/usr/local/lib/perl5/5.6.1
test.pl
1..1
ok 1
Can't call method "hexdigest" on an undefined value at
blib/lib/Crypt/SmbHash.pm line 65.
*** Error code 255
make: Fatal error: Command failed for target `test_dynamic'
so I fixed it:)
sub nthash($) {
my ( $pass ) = @_;
my ( $hex );
my ( $context );
$pass = substr($pass||"",0,128);
$pass =~ s/(.)/$1\000/sg;
if ( $HaveDigestMD4 ) {
$context = new Digest::MD4;
$context->add($pass);
$hex = $context->hexdigest;
$hex =~ tr/a-z/A-Z/;
}
else {
$hex = sprintf("%02X"x16,mdfour($pass));
}
return $hex;
}
and now all tests will be passed. perl 5.6.1.
toomas
--
Falling in love is a lot like dying.
You never get to do it enough to become good at it.
More information about the samba-technical
mailing list