Commit | Line | Data |
7b48dbf9 |
1 | #!./perl -Tw |
2 | |
3 | BEGIN { |
4 | chdir 't' if -d 't'; |
5 | @INC = ('../lib'); |
6 | } |
7 | |
17f79ebb |
8 | use Config; |
85c16d83 |
9 | |
7b48dbf9 |
10 | BEGIN { |
11 | require Test::More; |
12 | |
13 | if( !$Config{d_crypt} ) { |
14 | Test::More->import('skip_all'); |
15 | } |
16 | else { |
17 | Test::More->import(tests => 2); |
18 | } |
19 | } |
20 | |
85c16d83 |
21 | # Can't assume too much about the string returned by crypt(), |
22 | # and about how many bytes of the encrypted (really, hashed) |
23 | # string matter. |
24 | # |
25 | # HISTORICALLY the results started with the first two bytes of the salt, |
26 | # followed by 11 bytes from the set [./0-9A-Za-z], and only the first |
27 | # eight characters mattered, but those are probably no more safe |
28 | # bets, given alternative encryption/hashing schemes like MD5, |
29 | # C2 (or higher) security schemes, and non-UNIX platforms. |
30 | |
17f79ebb |
31 | SKIP: { |
32 | skip "crypt unimplemented", 2, unless $Config{d_crypt}; |
33 | |
8ce518b9 |
34 | ok(substr(crypt("ab", "cd"), 2) ne substr(crypt("ab", "ce"), 2), "salt makes a difference"); |
85c16d83 |
35 | |
8ce518b9 |
36 | ok(crypt("HI", "HO") eq crypt(join("",map{chr($_+256)}unpack"C*","HI"), "HO"), "low eight bits of Unicode"); |
17f79ebb |
37 | } |