This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Make crypt() do something more sane for Unicode
[perl5.git] / t / op / crypt.t
CommitLineData
85c16d83
JH
1use Test::More tests => 2;
2
3# Can't assume too much about the string returned by crypt(),
4# and about how many bytes of the encrypted (really, hashed)
5# string matter.
6#
7# HISTORICALLY the results started with the first two bytes of the salt,
8# followed by 11 bytes from the set [./0-9A-Za-z], and only the first
9# eight characters mattered, but those are probably no more safe
10# bets, given alternative encryption/hashing schemes like MD5,
11# C2 (or higher) security schemes, and non-UNIX platforms.
12
13ok(substr(crypt("ab", "cd"), 2) ne substr(crypt("ab", "ce"), 2), "salt");
14
15ok(crypt("HI", "HO") eq crypt(v4040.4041, "HO"), "Unicode");