1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
|
# Before `make install' is performed this script should be runnable with
# `make test'. After `make install' it should work as `perl test.pl'
#########################
# change 'tests => 1' to 'tests => last_test_to_print';
use Test;
BEGIN { plan tests => 1 };
use Crypt::SmbHash qw(ntlmgen lmhash nthash);
ok(1); # If we made it this far, we're ok.
#########################
# Insert your test code below, the Test module is use()ed here so read
# its man page ( perldoc Test ) for help writing this test script.
my ( $lm, $nt );
# Test Empty Password
ntlmgen "",$lm,$nt;
ok($lm,"AAD3B435B51404EEAAD3B435B51404EE");
ok($nt,"31D6CFE0D16AE931B73C59D7E0C089C0");
# Test password "0"
ntlmgen "0",$lm,$nt;
ok($lm,"25AD3B83FA6627C7AAD3B435B51404EE");
ok($nt,"7BC26760A19FC23E0996DAA99744CA80");
# Test simple password
ntlmgen "abcdef",$lm,$nt;
ok($lm,"13D855FC4841C7B1AAD3B435B51404EE");
ok($nt,"B5FE2DB507CC5AC540493D48FBD5FE33");
# Test long password
ntlmgen "abcdefghijklmnopqrstuvwxyabcdefghijklmnopqrstuvwxyabcdefghijklmnopqrstuvwxyabcdefghijklmnopqrstuvwxyabcdefghijklmnopqrstuvwxyabcdefghijklmnopqrstuvwxyabcdefghijklmnopqrstuvwxyabcdefghijklmnopqrstuvwxyabcdefghijklmnopqrstuvwxyzzzzzzzzz",$lm,$nt;
ok($lm,"E0C510199CC66ABD8C51EC214BEBDEA1");
ok($nt,"D71B61697C939BE27C14A7D7E23948EE");
# the next tests will fail if perl version <= 5.8
if ($] >= 5.008) {
require Encode;
import Encode;
# Test password with special chars (encoding here: utf8)
ntlmgen decode('utf8',"\303\266\303\244\303\274"),$lm,$nt;
ok($lm,"9983511F41C7B4C1AAD3B435B51404EE");
ok($nt,"4848BCB81CF018C3B70EA1479BD1374D");
# Test password with special chars (encoding here: latin1)
$lm = lmhash(decode('latin1', "\366\344\374"), "latin1");
$nt = nthash(decode('latin1', "\366\344\374"));
ok($lm,"9983511F41C7B4C1AAD3B435B51404EE");
ok($nt,"4848BCB81CF018C3B70EA1479BD1374D");
}
|