Authen-Passphrase
view release on metacpan or search on metacpan
t/vmspurdy.t view on Meta::CPAN
is $ppr->username, "ORINOCO";
is $ppr->salt, 15828;
is $ppr->salt_hex, "D43D";
is $ppr->hash, "\x6e\x82\xb5\x77\xfb\xb9\xcf\xd4";
is $ppr->hash_hex, "6E82B577FBB9CFD4";
is $ppr->as_crypt, '$VMS3$D43D6E82B577FBB9CFD4ORINOCO';
is $ppr->as_rfc2307, '{CRYPT}$VMS3$D43D6E82B577FBB9CFD4ORINOCO';
$ppr = Authen::Passphrase::VMSPurdy
->from_rfc2307('{CrYpT}$VMS3$D43D6E82B577FBB9CFD4ORINOCO');
ok $ppr;
is $ppr->algorithm, "PURDY_S";
is $ppr->username, "ORINOCO";
is $ppr->salt, 15828;
is $ppr->salt_hex, "D43D";
is $ppr->hash, "\x6e\x82\xb5\x77\xfb\xb9\xcf\xd4";
is $ppr->hash_hex, "6E82B577FBB9CFD4";
is $ppr->as_crypt, '$VMS3$D43D6E82B577FBB9CFD4ORINOCO';
is $ppr->as_rfc2307, '{CRYPT}$VMS3$D43D6E82B577FBB9CFD4ORINOCO';
foreach my $badpass ("", "a b", "1!", "oaoaoaoaoaoaoaoaoaoaoaoaoaoaoaoab") {
eval {
Authen::Passphrase::VMSPurdy
->new(username => "jrandom", salt => 1234,
passphrase => $badpass);
};
isnt $@, "";
}
my %pprs;
while(<DATA>) {
chomp;
s/([^ \n]+) ([^ \n]+) ([^ \n]+) ([^ \n]+) *//;
my($algorithm, $username, $salt, $hash_hex) = ($1, $2, $3, $4);
$ppr = Authen::Passphrase::VMSPurdy
->new(algorithm => $algorithm, username => $username,
salt => $salt, hash_hex => $hash_hex);
ok $ppr;
is $ppr->algorithm, $algorithm;
is $ppr->username, uc($username);
is $ppr->salt, $salt;
is $ppr->hash, pack("H*", $hash_hex);
is $ppr->hash_hex, uc($hash_hex);
eval { $ppr->passphrase }; isnt $@, "";
$pprs{$_} = $ppr;
}
foreach my $rightphrase (sort keys %pprs) {
my $ppr = $pprs{$rightphrase};
foreach my $passphrase (sort keys %pprs) {
ok ($ppr->match($passphrase) xor $passphrase ne $rightphrase);
}
}
1;
__DATA__
PURDY Chekov 63412 6ec0aed034aca888 0
PURDY_S Kirk 5623 4e9c1cf8b461c7ff 1
PURDY_V Spock 9084 7d63771C2BC9bb96 foo
PURDY_V Sulu 645 0bcedbfcec4dee1d supercalifragilisticexpialidocio
( run in 1.489 second using v1.01-cache-2.11-cpan-364913b4093 )