File: gendescrypt.t

package info (click to toggle)
libauthen-passphrase-perl 0.008-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 376 kB
  • sloc: perl: 1,932; makefile: 2
file content (46 lines) | stat: -r--r--r-- 1,150 bytes parent folder | download | duplicates (5)
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
use warnings;
use strict;

use Test::More tests => 71;

BEGIN { use_ok "Authen::Passphrase::DESCrypt"; }

my %pprs;
while(<DATA>) {
	chomp;
	s/([^ \n]+) ([^ \n]+) ([^ \n]+) ([^ \n]+) *//;
	my($nrounds, $salt, $initial, $hash) = ($1, $2, $3, $4);
	my $ppr = Authen::Passphrase::DESCrypt
			->new(fold => 1, initial_base64 => $initial,
			      nrounds_base64 => $nrounds,
			      salt_base64 => $salt, hash_base64 => $hash);
	ok $ppr;
	ok $ppr->fold;
	is $ppr->nrounds_base64_4, $nrounds;
	is $ppr->salt_base64_4, $salt;
	is $ppr->initial_base64, $initial;
	is $ppr->hash_base64, $hash;
	eval { $ppr->passphrase };
	isnt $@, "";
	eval { $ppr->as_crypt };
	isnt $@, "";
	eval { $ppr->as_rfc2307 };
	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__
xIw. Alif bXjK3LN9iE2 6UN3gAqtTbM
Eoz. jn35 ACp9yg0cqDM puFoxi30V2o 0
6.d. UyXU yaNPU/4ioNk ZxMRQY8Bpdo 1
Ogc. qu8. YN9krx1eBSE Vcrdw3DtWc6 foo
bAy. XCaN EwD4x5Zn7lY 7KB8x6lwKIQ supercalifragilisticexpialidocious