summaryrefslogtreecommitdiff
path: root/t/op/crypt.t
diff options
context:
space:
mode:
authorJarkko Hietaniemi <jhi@iki.fi>2001-09-03 19:50:57 +0000
committerJarkko Hietaniemi <jhi@iki.fi>2001-09-03 19:50:57 +0000
commit85c16d835facb3e1567f0ad453769c0d9a8da60b (patch)
tree18e98ac37b49f61765b436c2fb4fcc0f200c99a7 /t/op/crypt.t
parent0686c0b8fd853975c64d3472ef479435ba920e0a (diff)
downloadperl-85c16d835facb3e1567f0ad453769c0d9a8da60b.tar.gz
Make crypt() do something more sane for Unicode
(take crypt() of the low eight bits of the characters, instead of taking crypt() of the UTF-8 of the scalar); add a test for crypt(). p4raw-id: //depot/perl@11852
Diffstat (limited to 't/op/crypt.t')
-rw-r--r--t/op/crypt.t15
1 files changed, 15 insertions, 0 deletions
diff --git a/t/op/crypt.t b/t/op/crypt.t
new file mode 100644
index 0000000000..26eb06a580
--- /dev/null
+++ b/t/op/crypt.t
@@ -0,0 +1,15 @@
+use Test::More tests => 2;
+
+# Can't assume too much about the string returned by crypt(),
+# and about how many bytes of the encrypted (really, hashed)
+# string matter.
+#
+# HISTORICALLY the results started with the first two bytes of the salt,
+# followed by 11 bytes from the set [./0-9A-Za-z], and only the first
+# eight characters mattered, but those are probably no more safe
+# bets, given alternative encryption/hashing schemes like MD5,
+# C2 (or higher) security schemes, and non-UNIX platforms.
+
+ok(substr(crypt("ab", "cd"), 2) ne substr(crypt("ab", "ce"), 2), "salt");
+
+ok(crypt("HI", "HO") eq crypt(v4040.4041, "HO"), "Unicode");